(.require [library [lux (.except) [abstract ["[0]" monad (.only do)]] [control ["[0]" maybe] ["[0]" try (.only Try)] ["[0]" exception] [concurrency ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]] [data ["[0]" binary (.use "[1]#[0]" equivalence) ["[0]" \\format]] ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)] [encoding ["[0]" utf8]]] ["[0]" format ["[0]" tar] ["[0]" xml]] [collection ["[0]" set]]] [math ["[0]" random]] [meta [compiler [meta ["[0]" export]]]] [world ["[0]" file] ["[0]" shell (.only Process Shell)] ["[0]" environment ["program" / (.only Environment)] ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] ["$" // ["[1][0]" install] ["[1][0]" version] [// ["[1][0]" profile] ["[1][0]" repository]]] [\\program ["[0]" / (.only) ["/[1]" // ["[1][0]" install] ["/[1]" // ["[1]" profile] ["[1][0]" action] ["[1][0]" pom] ["[1][0]" hash] ["[1][0]" repository (.only Repository) ["[1]/[0]" local] ["[1]/[0]" remote]] ["[1][0]" artifact (.only Artifact) ["[1]/[0]" extension]]]]]]) (def (shell fs) (-> (file.System Async) (Shell Async)) (implementation (def (execute [environment working_directory command arguments]) (do [! ///action.monad] [files (at fs directory_files working_directory) _ (monad.each ! (function (_ file) (do ! [_ (is (Async (Try Any)) (file.copy async.monad fs file (format file ".asc")))] (in []))) files)] (<| in (is (Process Async)) (implementation (def (read _) (async#in (exception.except shell.no_more_output []))) (def (fail _) (async#in (exception.except shell.no_more_output []))) (def (write input) (async#in {try.#Failure "write"})) (def (destroy _) (async#in {try.#Failure "destroy"})) (def (await _) (in shell.error)))))))) (def (execute! program local remote fs artifact profile) (-> (Environment Async) (Repository Async) (Repository Async) (file.System Async) Artifact ///.Profile (Async (Try [Text Text]))) (do ///action.monad [.let [console ($version.echo "")] _ ($install.make_sources! fs (the ///.#sources profile)) _ (/.do! program (..shell fs) console local remote fs artifact profile) locally_installed! (at console read_line []) deployed! (at console read_line [])] (in [locally_installed! deployed!]))) (def .public test Test (<| (_.covering /._) (do [! random.monad] [[artifact expected_pom profile] (random.one (function (_ profile) (do maybe.monad [artifact (the ///.#identity profile) expected_pom (try.maybe (///pom.write profile))] (in [artifact expected_pom profile]))) $profile.random) home (random.alphabetic 5) working_directory (random.alphabetic 5) .let [fs (file.mock (at file.default separator)) program (program.async (program.mock environment.empty home working_directory)) local (///repository/local.repository program fs) remote (///repository.mock $repository.mock $repository.empty)]] (in (do [! async.monad] [verdict (do [! ///action.monad] [[locally_installed! deployed!] (..execute! program local remote fs artifact profile) expected_library (|> profile (the ///.#sources) set.list (export.library fs) (at ! each (\\format.result tar.format))) actual_pom (at remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact ///artifact/extension.pom)) actual_library (at remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact ///artifact/extension.lux_library)) actual_sha1 (at remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.sha1))) actual_sha1 (at async.monad in (do try.monad [actual_sha1 (at utf8.codec decoded actual_sha1)] (at ///hash.sha1_codec decoded actual_sha1))) actual_md5 (at remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) actual_md5 (at async.monad in (do try.monad [actual_md5 (at utf8.codec decoded actual_md5)] (at ///hash.md5_codec decoded actual_md5))) .let [succeeded! (and (text#= //install.success locally_installed!) (text#= /.success deployed!)) deployed_library! (binary#= expected_library actual_library) deployed_pom! (binary#= (|> expected_pom (at xml.codec encoded) (at utf8.codec encoded)) actual_pom) deployed_sha1! (at ///hash.equivalence = (///hash.sha1 expected_library) actual_sha1) deployed_md5! (at ///hash.equivalence = (///hash.md5 expected_library) actual_md5)]] (in (and succeeded! deployed_library! deployed_pom! deployed_sha1! deployed_md5!)))] (unit.coverage [/.do! /.success] (try.else false verdict)))))))