(.module: [library [lux #* ["_" test (#+ Test)] [abstract [monad (#+ do)]] [control ["." try (#+ Try)] [concurrency ["." promise (#+ Promise)]] [parser ["." environment]]] [data ["." maybe] ["." binary ("#\." equivalence)] ["." text ("#\." equivalence) ["%" format (#+ format)] [encoding ["." utf8]]] ["." format #_ ["#" binary] ["." tar] ["." xml]] [collection ["." set]]] [math ["." random]] [world ["." file] ["." program (#+ Program)]]]] [program [compositor ["." export]]] [// ["$." install] ["$." version] [// ["$." profile] ["$." repository]]] [\\program ["." / ["//#" /// #_ ["#" profile] ["#." action] ["#." pom] ["#." hash] ["#." repository (#+ Repository) ["#/." remote]] ["#." artifact (#+ Artifact) ["#/." extension]]]]]) (def: (execute! program repository fs artifact profile) (-> (Program Promise) (Repository Promise) (file.System Promise) Artifact ///.Profile (Promise (Try Text))) (do ///action.monad [#let [console ($version.echo "")] _ ($install.make_sources! fs (get@ #///.sources profile)) _ (/.do! console repository fs artifact profile)] (\ console read_line []))) (def: #export test Test (<| (_.covering /._) (do {! random.monad} [[artifact expected_pom profile] (random.one (function (_ profile) (do maybe.monad [artifact (get@ #///.identity profile) expected_pom (try.to_maybe (///pom.write profile))] (wrap [artifact expected_pom profile]))) $profile.random) home (random.ascii/alpha 5) working_directory (random.ascii/alpha 5) #let [repository (///repository.mock $repository.mock $repository.empty) fs (file.mock (\ file.default separator)) program (program.async (program.mock environment.empty home working_directory))]] (wrap (do {! promise.monad} [verdict (do {! ///action.monad} [logging (..execute! program repository fs artifact profile) expected_library (|> profile (get@ #///.sources) set.to_list (export.library fs) (\ ! map (format.run tar.writer))) actual_pom (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact ///artifact/extension.pom)) actual_library (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact ///artifact/extension.lux_library)) actual_sha-1 (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.sha-1))) actual_sha-1 (\ promise.monad wrap (do try.monad [actual_sha-1 (\ utf8.codec decode actual_sha-1)] (\ ///hash.sha-1_codec decode actual_sha-1))) actual_md5 (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) actual_md5 (\ promise.monad wrap (do try.monad [actual_md5 (\ utf8.codec decode actual_md5)] (\ ///hash.md5_codec decode actual_md5))) #let [succeeded! (text\= /.success logging) deployed_library! (binary\= expected_library actual_library) deployed_pom! (binary\= (|> expected_pom (\ xml.codec encode) (\ utf8.codec encode)) actual_pom) deployed_sha-1! (\ ///hash.equivalence = (///hash.sha-1 expected_library) actual_sha-1) deployed_md5! (\ ///hash.equivalence = (///hash.md5 expected_library) actual_md5)]] (wrap (and succeeded! deployed_library! deployed_pom! deployed_sha-1! deployed_md5!)))] (_.cover' [/.do! /.success] (try.default false verdict)))))))