From db3e864ae66da7f7d1034ae95967605144d5ec47 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 27 Jun 2021 20:09:48 -0400 Subject: Made obtaining env variables more granular + partial Lua support. --- stdlib/source/test/aedifex/command/auto.lux | 43 +++++++++----------- stdlib/source/test/aedifex/command/build.lux | 12 +----- stdlib/source/test/aedifex/command/clean.lux | 54 +++++++++++--------------- stdlib/source/test/aedifex/command/deploy.lux | 4 +- stdlib/source/test/aedifex/command/deps.lux | 7 +--- stdlib/source/test/aedifex/command/install.lux | 4 +- stdlib/source/test/aedifex/command/pom.lux | 4 +- stdlib/source/test/aedifex/command/test.lux | 2 +- 8 files changed, 50 insertions(+), 80 deletions(-) (limited to 'stdlib/source/test/aedifex/command') diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index c23519bcc..7ef74d2c0 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -14,7 +14,9 @@ ["!" capability]]] [data ["." text - ["%" format (#+ format)]] + ["%" format (#+ format)] + [encoding + ["." utf8]]] [collection ["." dictionary] ["." set] @@ -27,7 +29,7 @@ [console (#+ Console)] ["." shell (#+ Shell)] ["." program (#+ Program)] - ["." file (#+ Path) + ["." file (#+ Path File) ["." watch]]]] ["." // #_ ["@." version] @@ -47,28 +49,22 @@ ["#." dependency ["#/." resolution (#+ Resolution)]]]]]}) -(def: (command end_signal dummy_files) - (-> Text (List Path) - [(Atom [Nat (List Path)]) +(def: (command expected_runs end_signal dummy_file) + (-> Nat Text (File Promise) + [(Atom Nat) (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any))]) - (let [@runs (: (Atom [Nat (List Path)]) - (atom.atom [0 dummy_files]))] + (let [@runs (: (Atom Nat) + (atom.atom 0))] [@runs (function (_ console program fs shell resolution profile) (do {! promise.monad} - [[_ [runs remaining_files]] (promise.future - (atom.update (function (_ [runs remaining_files]) - [(inc runs) remaining_files]) - @runs))] - (case remaining_files - #.Nil + [[_ actual_runs] (promise.future (atom.update inc @runs))] + (if (n.= expected_runs actual_runs) (wrap (#try.Failure end_signal)) - - (#.Cons head tail) (do (try.with !) - [_ (!.use (\ fs create_file) [head])] + [_ (!.use (\ dummy_file over_write) (\ utf8.codec encode (%.nat actual_runs)))] (do ! - [_ (promise.future (atom.write [runs tail] @runs))] + [_ (promise.future (atom.write actual_runs @runs))] (wrap (#try.Success [])))))))])) (def: #export test @@ -85,7 +81,7 @@ #let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) - (set@ #///.target (#.Some target))) + (set@ #///.target target)) with_program (: (-> Profile Profile) (set@ #///.program (#.Some program))) @@ -98,15 +94,14 @@ working_directory (random.ascii/alpha 5) expected_runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat) - dummy_files (|> (random.ascii/alpha 5) - (random.set text.hash (dec expected_runs)) - (\ ! map (|>> set.to_list (list\map (|>> (format source /)))))) + dummy_path (\ ! map (|>> (format source /)) (random.ascii/alpha 5)) resolution @build.resolution] ($_ _.and (wrap (do promise.monad [verdict (do ///action.monad - [#let [[@runs command] (..command end_signal dummy_files)] - _ (!.use (\ fs create_directory) [source]) + [_ (!.use (\ fs create_directory) [source]) + dummy_file (!.use (\ fs create_file) [dummy_path]) + #let [[@runs command] (..command expected_runs end_signal dummy_file)] _ (\ watcher poll [])] (do promise.monad [outcome ((/.do! 1 watcher command) @@ -116,7 +111,7 @@ (shell.async (@build.good_shell [])) resolution profile) - [actual_runs _] (promise.future (atom.read @runs))] + actual_runs (promise.future (atom.read @runs))] (wrap (#try.Success (and (n.= expected_runs actual_runs) (case outcome (#try.Failure error) diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 234343fea..7fd8c3eb3 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -109,7 +109,7 @@ #let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) - (set@ #///.target (#.Some target))) + (set@ #///.target target)) with_program (: (-> Profile Profile) (set@ #///.program (#.Some program))) @@ -127,16 +127,6 @@ (#try.Failure error) (exception.match? /.no_specified_program error))))) - (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty - (with_program empty_profile))] - (_.cover' [/.no_specified_target] - (case outcome - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.no_specified_target error))))) (wrap (do promise.monad [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty profile)] (_.cover' [/.Compiler /.no_available_compiler] diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index d98473259..705cca7f2 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -99,35 +99,25 @@ sub_files (..files (format sub_path /)) dummy @profile.random] - ($_ _.and - (wrap (do promise.monad - [#let [console (@version.echo "")] - verdict (do {! (try.with promise.monad)} - [_ (/.do! console fs (set@ #///.target #.None dummy))] - (\ ! map (text\= /.failure) - (!.use (\ console read_line) [])))] - (_.cover' [/.failure] - (try.default false verdict)))) - (wrap (do promise.monad - [#let [console (@version.echo "")] - verdict (do {! (try.with promise.monad)} - [_ (..create_directory! fs target_path direct_files) - _ (..create_directory! fs sub_path sub_files) - context_exists!/pre (..directory_exists? fs context) - target_exists!/pre (..assets_exist? fs target_path direct_files) - sub_exists!/pre (..assets_exist? fs sub_path sub_files) - _ (/.do! console fs (set@ #///.target (#.Some target_path) dummy)) - context_exists!/post (..directory_exists? fs context) - target_exists!/post (..assets_exist? fs target_path direct_files) - sub_exists!/post (..assets_exist? fs sub_path sub_files) - logging (!.use (\ console read_line) [])] - (wrap (and (and context_exists!/pre - context_exists!/post) - (and target_exists!/pre - (not target_exists!/post)) - (and sub_exists!/pre - (not sub_exists!/post)) - (text\= /.success logging))))] - (_.cover' [/.do! /.success] - (try.default false verdict)))) - )))) + (wrap (do promise.monad + [#let [console (@version.echo "")] + verdict (do {! (try.with promise.monad)} + [_ (..create_directory! fs target_path direct_files) + _ (..create_directory! fs sub_path sub_files) + context_exists!/pre (..directory_exists? fs context) + target_exists!/pre (..assets_exist? fs target_path direct_files) + sub_exists!/pre (..assets_exist? fs sub_path sub_files) + _ (/.do! console fs (set@ #///.target target_path dummy)) + context_exists!/post (..directory_exists? fs context) + target_exists!/post (..assets_exist? fs target_path direct_files) + sub_exists!/post (..assets_exist? fs sub_path sub_files) + logging (!.use (\ console read_line) [])] + (wrap (and (and context_exists!/pre + context_exists!/post) + (and target_exists!/pre + (not target_exists!/post)) + (and sub_exists!/pre + (not sub_exists!/post)) + (text\= (/.success target_path) logging))))] + (_.cover' [/.do! /.success] + (try.default false verdict))))))) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index cc99f2e48..7e1bf166e 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -123,7 +123,7 @@ (\ ///hash.md5_codec decode actual_md5))) #let [succeeded! - (text\= //clean.success logging) + (text\= /.success logging) deployed_library! (\ binary.equivalence = @@ -149,5 +149,5 @@ deployed_pom! deployed_sha-1! deployed_md5!)))] - (_.cover' [/.do!] + (_.cover' [/.do! /.success] (try.default false verdict))))))) diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 8b5e3820e..2b4898dd3 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -107,9 +107,6 @@ (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee depender))) (/.do! console local (list (///repository.mock ($///dependency/resolution.single depender_artifact depender_package) [])))) - logging! (\ ///action.monad map - (text\= //clean.success) - (!.use (\ console read_line) [])) #let [had_dependee_before! (set.member? pre dependee_artifact) @@ -122,9 +119,7 @@ had_depender_after! (dictionary.key? post depender)]] - (wrap (and logging! - - had_dependee_before! + (wrap (and had_dependee_before! lacked_depender_before! had_dependee_after! diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 33ee7192d..8096fc2b2 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -92,7 +92,7 @@ library_path (format artifact_path ///artifact/extension.lux_library) pom_path (format artifact_path ///artifact/extension.pom)] - #let [succeeded! (text\= //clean.success logging)] + #let [succeeded! (text\= /.success logging)] library_exists! (\ promise.monad map exception.return (file.file_exists? promise.monad fs library_path)) @@ -102,7 +102,7 @@ (wrap (and succeeded! library_exists! pom_exists!)))] - (_.cover' [/.do!] + (_.cover' [/.do! /.success] (try.default false verdict)))) (wrap (do {! promise.monad} [#let [fs (file.mock (\ file.default separator)) diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux index c368d5f84..f7f182225 100644 --- a/stdlib/source/test/aedifex/command/pom.lux +++ b/stdlib/source/test/aedifex/command/pom.lux @@ -54,7 +54,7 @@ actual (!.use (\ file content) []) logging! (\ ///action.monad map - (text\= //clean.success) + (text\= /.success) (!.use (\ console read_line) [])) #let [expected_path! @@ -65,7 +65,7 @@ (wrap (and logging! expected_path! expected_content!)))] - (_.cover' [/.do!] + (_.cover' [/.do! /.success] (try.default false verdict))) (#try.Failure error) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index 6b7ba9324..291b31863 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -51,7 +51,7 @@ #let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) - (set@ #///.target (#.Some target))) + (set@ #///.target target)) with_test (: (-> Profile Profile) (set@ #///.test (#.Some test))) -- cgit v1.2.3