From 772f621c19408c711c1e587668a52a8cfeeea418 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 12 Aug 2022 22:26:57 -0400 Subject: Fixes for Aedifex tests. --- .../aedifex/artifact/snapshot/version/value.lux | 5 +- stdlib/source/test/aedifex/artifact/time/date.lux | 7 +- stdlib/source/test/aedifex/artifact/time/time.lux | 3 +- stdlib/source/test/aedifex/cli.lux | 10 +-- stdlib/source/test/aedifex/command/auto.lux | 13 +-- stdlib/source/test/aedifex/command/build.lux | 11 +-- stdlib/source/test/aedifex/command/deploy.lux | 99 ++++++++++++++-------- stdlib/source/test/aedifex/command/deps.lux | 15 ++-- stdlib/source/test/aedifex/command/install.lux | 12 +-- stdlib/source/test/aedifex/command/test.lux | 11 +-- .../source/test/aedifex/dependency/resolution.lux | 3 +- stdlib/source/test/aedifex/input.lux | 13 +-- stdlib/source/test/aedifex/metadata/artifact.lux | 6 +- stdlib/source/test/aedifex/metadata/snapshot.lux | 8 +- stdlib/source/test/aedifex/parser.lux | 31 ++++--- stdlib/source/test/aedifex/profile.lux | 23 +++-- stdlib/source/test/aedifex/repository.lux | 2 +- stdlib/source/test/aedifex/repository/local.lux | 6 +- 18 files changed, 162 insertions(+), 116 deletions(-) (limited to 'stdlib/source/test/aedifex') diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux index 470cd66c7..f116a0a78 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux @@ -16,8 +16,9 @@ [number ["n" nat] ["i" int]]] - [time - ["[0]" instant]] + [world + [time + ["[0]" instant]]] [test ["_" property (.only Test)]]]] ["$[0]" /// diff --git a/stdlib/source/test/aedifex/artifact/time/date.lux b/stdlib/source/test/aedifex/artifact/time/date.lux index 5efc00d4e..23f0a69f8 100644 --- a/stdlib/source/test/aedifex/artifact/time/date.lux +++ b/stdlib/source/test/aedifex/artifact/time/date.lux @@ -16,9 +16,10 @@ [number ["n" nat] ["i" int]]] - [time - ["[0]" date (.use "[1]#[0]" equivalence)] - ["[0]" year]] + [world + [time + ["[0]" date (.use "[1]#[0]" equivalence)] + ["[0]" year]]] [test ["_" property (.only Test)]]]] [\\program diff --git a/stdlib/source/test/aedifex/artifact/time/time.lux b/stdlib/source/test/aedifex/artifact/time/time.lux index d4bc90f4e..90ac9819b 100644 --- a/stdlib/source/test/aedifex/artifact/time/time.lux +++ b/stdlib/source/test/aedifex/artifact/time/time.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["[0]" time] [abstract [monad (.only do)]] [control @@ -14,6 +13,8 @@ [number ["n" nat] ["i" int]]] + [world + ["[0]" time]] [test ["_" property (.only Test)]]]] [\\program diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index b388866c6..fa6d9c72c 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -7,15 +7,15 @@ ["$[0]" equivalence]]] [control ["[0]" pipe] - ["[0]" try] - [parser - ["[0]" cli]]] + ["[0]" try]] [data ["[0]" text] [collection ["[0]" list]]] [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)]] + [program + ["cli" \\parser]] [test ["_" property (.only Test)]]]] [\\program @@ -79,7 +79,7 @@ (cli.result /.command) (pipe.when {try.#Success [names actual]} - (and (at (list.equivalence text.equivalence) = (list //.default) names) + (and (at (list.equivalence text.equivalence) = (list) names) (at /.equivalence = expected actual)) {try.#Failure error} @@ -97,7 +97,7 @@ (cli.result /.command) (pipe.when {try.#Success [actual_profile actual_command]} - (and (at (list.equivalence text.equivalence) = (list expected_profile //.default) actual_profile) + (and (at (list.equivalence text.equivalence) = (list expected_profile) actual_profile) (at /.equivalence = expected_command actual_command)) {try.#Failure error} diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index b202af97f..c46b474ac 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -6,8 +6,6 @@ [control ["[0]" pipe] ["[0]" try] - [parser - ["[0]" environment]] [concurrency ["[0]" atom (.only Atom)] ["[0]" async (.only Async)]]] @@ -26,8 +24,10 @@ [world [console (.only Console)] ["[0]" shell (.only Exit Shell)] - ["[0]" program (.only Program)] - ["[0]" file + ["[0]" environment + ["program" / (.only Environment)] + ["[1]" \\parser]] + ["[0]" file (.only) ["[0]" watch]] [time ["[0]" instant]]] @@ -49,7 +49,7 @@ (def (command expected_runs end_signal fs dummy_file) (-> Nat Text (file.System Async) file.Path [(Atom Nat) - (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Any]))]) + (-> (Console Async) (Environment Async) (file.System Async) (Shell Async) Resolution (Command [Exit Any]))]) (let [@runs (is (Atom Nat) (atom.atom 0))] [@runs @@ -71,7 +71,8 @@ .let [/ (at file.default separator) [fs watcher] (watch.mock /)] - program (random.alphabetic 5) + program (random.and (random.alphabetic 5) + (random.alphabetic 5)) target (random.alphabetic 5) source (random.alphabetic 5) .let [empty_profile (is Profile diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index c039b6e9c..674a04e93 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -9,9 +9,7 @@ ["[0]" try] ["[0]" exception] [concurrency - ["[0]" async (.only Async)]] - [parser - ["[0]" environment]]] + ["[0]" async (.only Async)]]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection @@ -21,7 +19,9 @@ [world ["[0]" file] ["[0]" shell (.only Shell)] - ["[0]" program]] + ["[0]" environment + ["program" /] + ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] @@ -146,7 +146,8 @@ last_error (random.alphabetic 5) .let [fs (file.mock (at file.default separator)) shell (shell.async (..good_shell []))] - program (random.alphabetic 5) + program (random.and (random.alphabetic 5) + (random.alphabetic 5)) target (random.alphabetic 5) home (random.alphabetic 5) working_directory (random.alphabetic 5) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 55fac78c6..6e8d38d31 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -2,22 +2,21 @@ [library [lux (.except) [abstract - [monad (.only do)]] + ["[0]" monad (.only do)]] [control ["[0]" maybe] ["[0]" try (.only Try)] + ["[0]" exception] [concurrency - ["[0]" async (.only Async)]] - [parser - ["[0]" environment]]] + ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]] [data - ["[0]" binary (.use "[1]#[0]" equivalence)] + ["[0]" binary (.use "[1]#[0]" equivalence) + ["[0]" \\format]] ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)] [encoding ["[0]" utf8]]] ["[0]" format - ["[1]" binary] ["[0]" tar] ["[0]" xml]] [collection @@ -30,41 +29,74 @@ ["[0]" export]]]] [world ["[0]" file] - ["[0]" program (.only Program)] - ["[0]" shell]] + ["[0]" shell (.only Process Shell)] + ["[0]" environment + ["program" / (.only Environment)] + ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] - [// - ["$[0]" build] - ["$[0]" install] - ["$[0]" version] + ["$" // + ["[1][0]" install] + ["[1][0]" version] [// - ["$[0]" profile] - ["$[0]" repository]]] + ["[1][0]" profile] + ["[1][0]" repository]]] [\\program ["[0]" / (.only) - ["//[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]]]]]) + ["/[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) - (-> (Program Async) (Repository Async) (Repository Async) (file.System Async) + (-> (Environment Async) (Repository Async) (Repository Async) (file.System Async) Artifact ///.Profile - (Async (Try Text))) + (Async (Try [Text Text]))) (do ///action.monad - [.let [console ($version.echo "") - shell (shell.async ($build.bad_shell []))] + [.let [console ($version.echo "")] _ ($install.make_sources! fs (the ///.#sources profile)) - _ (/.do! program shell console local remote fs artifact profile)] - (at console read_line []))) + _ (/.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 @@ -87,12 +119,12 @@ $repository.empty)]] (in (do [! async.monad] [verdict (do [! ///action.monad] - [logging (..execute! program local remote fs artifact profile) + [[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))) + (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)) @@ -108,7 +140,8 @@ (at ///hash.md5_codec decoded actual_md5))) .let [succeeded! - (text#= /.success logging) + (and (text#= //install.success locally_installed!) + (text#= /.success deployed!)) deployed_library! (binary#= expected_library diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 15d5e3986..64060127b 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -2,14 +2,13 @@ [library [lux (.except) [abstract - [monad (.only do)] - ["[0]" predicate]] + [monad (.only do)]] [control ["[0]" try] + [function + ["[0]" predicate]] [concurrency - ["[0]" async]] - [parser - ["[0]" environment]]] + ["[0]" async]]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)] @@ -23,8 +22,10 @@ [math ["[0]" random (.only Random)]] [world - ["[0]" program] - ["[0]" file]] + ["[0]" file] + ["[0]" environment + ["program" /] + ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index ff8bca5e9..d942a9d17 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -7,9 +7,7 @@ ["[0]" try (.only Try) (.use "[1]#[0]" functor)] ["[0]" exception] [concurrency - ["[0]" async (.only Async)]] - [parser - ["[0]" environment]]] + ["[0]" async (.only Async)]]] [data ["[0]" binary] ["[0]" text (.use "[1]#[0]" equivalence) @@ -20,7 +18,9 @@ ["[0]" random]] [world ["[0]" file] - ["[0]" program (.only Program)]] + ["[0]" environment + ["program" / (.only Environment)] + ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] @@ -31,7 +31,7 @@ ["$[0]" artifact]]] [\\program ["[0]" / (.only) - ["/[1]" /// + ["//[1]" /// ["[1]" profile] ["[1][0]" action (.only Action)] ["[1][0]" local] @@ -54,7 +54,7 @@ (file.make_file async.monad fs (binary.empty 0) (format head / head ".lux"))))))))) (def (execute! program fs sample) - (-> (Program Async) (file.System Async) ///.Profile (Async (Try Text))) + (-> (Environment Async) (file.System Async) ///.Profile (Async (Try Text))) (do ///action.monad [.let [console ($version.echo "")] _ (..make_sources! fs (the ///.#sources sample)) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index 1209b4020..31afea06b 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -7,9 +7,7 @@ ["[0]" try] ["[0]" exception] [concurrency - ["[0]" async]] - [parser - ["[0]" environment]]] + ["[0]" async]]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection @@ -20,7 +18,9 @@ [world ["[0]" file] ["[0]" shell] - ["[0]" program]] + ["[0]" environment + ["program" /] + ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] @@ -45,7 +45,8 @@ Test (<| (_.covering /._) (do [! random.monad] - [test (random.alphabetic 5) + [test (random.and (random.alphabetic 5) + (random.alphabetic 5)) target (random.alphabetic 5) home (random.alphabetic 5) working_directory (random.alphabetic 5) diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 0f353d828..ad9d9033f 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -3,12 +3,13 @@ [lux (.except all) [abstract [monad (.only do)] - ["[0]" predicate] [\\specification ["$[0]" equivalence]]] [control ["[0]" try] ["[0]" exception] + [function + ["[0]" predicate]] [concurrency ["[0]" async]]] [data diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index 9c296e12c..7dc6ccc8e 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -43,6 +43,11 @@ (-> (Set Address) (Set Address)) (set.has //.default_repository)) +(def with_defaults + (-> Profile Profile) + (|>> (revised //.#sources ..with_default_source) + (revised //.#repositories ..with_default_repository))) + (def .public test Test (<| (_.covering /._) @@ -59,11 +64,7 @@ (at utf8.codec encoded))] _ (at fs write //project.file profile) actual (is (Async (Try Profile)) - (/.read async.monad fs (list //.default)))] - (in (at //.equivalence = - (|> expected - (revised //.#sources ..with_default_source) - (revised //.#repositories ..with_default_repository)) - actual)))] + (/.read async.monad fs (list)))] + (in (at //.equivalence = (with_defaults expected) actual)))] (unit.coverage [/.read] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index f2d430fb2..27c194d84 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -8,8 +8,6 @@ [control ["[0]" maybe] ["[0]" try (.use "[1]#[0]" functor)] - [parser - ["[0]" environment]] [concurrency ["[0]" async]]] [data @@ -27,7 +25,9 @@ ["[0]" code]] [world ["[0]" file] - ["[0]" program] + ["[0]" environment + ["program" /] + ["[1]" \\parser]] ["[0]" time (.only) ["[0]" date] ["[0]" year] diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index 34965c98a..fa26186ea 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -8,8 +8,6 @@ [control ["[0]" maybe] ["[0]" try (.use "[1]#[0]" functor)] - [parser - ["[0]" environment]] [concurrency ["[0]" async]]] [data @@ -27,7 +25,9 @@ ["[0]" code]] [world ["[0]" file] - ["[0]" program] + ["[0]" environment + ["program" /] + ["[1]" \\parser]] ["[0]" time (.only) ["[0]" date] ["[0]" year] @@ -38,7 +38,7 @@ ["[0]" unit] ["_" property (.only Test)]]]] ["$[0]" /// - ["[1][0]" artifact + ["[1][0]" artifact (.only) ["[1]/[0]" type] ["[1]/[0]" time] ["[1]/[0]" snapshot diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 54cdbc17a..cbc67dbab 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -6,7 +6,7 @@ [hash (.only Hash)]] [control ["[0]" pipe] - ["[0]" try]] + ["[0]" try (.use "[1]#[0]" functor)]] [data ["[0]" text] [collection @@ -40,7 +40,7 @@ (def (list_of random) (All (_ a) (-> (Random a) (Random (List a)))) (do [! random.monad] - [size (at ! each (n.% 5) random.nat)] + [size (at ! each (|>> (n.% 5) ++) random.nat)] (random.list size random))) (def (dictionary_of key_hash key_random value_random) @@ -72,6 +72,16 @@ (//project.project //.default (at //.monoid identity)) project)) +(def with_defaults + (-> Project Project) + (|>> ..with_empty_profile + dictionary.entries + (list#each (function (_ [name profile]) + [name (|> profile + ..with_default_sources + ..with_default_repository)])) + (dictionary.of_list text.hash))) + (def .public test Test (<| (_.covering /._) @@ -84,17 +94,6 @@ //format.project list (.result /.project) - (pipe.when - {try.#Success actual} - (|> expected - ..with_empty_profile - dictionary.entries - (list#each (function (_ [name profile]) - [name (|> profile - ..with_default_sources - ..with_default_repository)])) - (dictionary.of_list text.hash) - (at //project.equivalence = actual)) - - {try.#Failure error} - false)))))) + (try#each (at //project.equivalence = (..with_defaults expected))) + (try.else false) + ))))) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 9a2c5ba3c..4d964ebdd 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except) + [lux (.except symbol) [abstract [monad (.only do)] [hash (.only Hash)] @@ -8,9 +8,7 @@ ["$[0]" equivalence] ["$[0]" monoid]]] [control - ["[0]" try] - [parser - ["[0]" cli]]] + ["[0]" try]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection @@ -26,6 +24,8 @@ [cli ["[0]" compiler (.only) ["$[1]" \\test]]]]]] + [program + ["cli" \\parser]] [test ["_" property (.only Test)]]]] [// @@ -124,6 +124,11 @@ (Random /.Target) (random.alphabetic 1)) +(def (symbol module_size short_size) + (-> Nat Nat (Random Symbol)) + (random.and (random.alphabetic module_size) + (random.alphabetic short_size))) + (def .public random (Random /.Profile) (all random.and @@ -136,11 +141,11 @@ (..list_of $compiler.random) (..set_of text.hash ..source) ..target - (random.maybe (random.alphabetic 1)) - (random.maybe (random.alphabetic 2)) - (..dictionary_of text.hash (random.alphabetic 3) ..repository) - (..list_of (random.and (random.alphabetic 4) - (random.alphabetic 5))) + (random.maybe (symbol 1 2)) + (random.maybe (symbol 3 4)) + (..dictionary_of text.hash (random.alphabetic 5) ..repository) + (..list_of (random.and (random.alphabetic 6) + (random.alphabetic 7))) (random#in //runtime.default_java) (random#in //runtime.default_js) (random#in //runtime.default_python) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index fd26f3898..f61f1ec50 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -8,7 +8,7 @@ [control ["[0]" io] ["[0]" try] - ["[0]" exception (.only exception)]] + ["[0]" exception (.only Exception)]] [data ["[0]" product] ["[0]" binary (.only Binary)] diff --git a/stdlib/source/test/aedifex/repository/local.lux b/stdlib/source/test/aedifex/repository/local.lux index 96a07f678..874c773b3 100644 --- a/stdlib/source/test/aedifex/repository/local.lux +++ b/stdlib/source/test/aedifex/repository/local.lux @@ -5,8 +5,6 @@ [monad (.only do)]] [control ["[0]" try (.use "[1]#[0]" functor)] - [parser - ["[0]" environment]] [concurrency ["[0]" async]]] [data @@ -18,7 +16,9 @@ ["[0]" random]] [world ["[0]" file] - ["[0]" program]] + ["[0]" environment + ["program" /] + ["[1]" \\parser]]] [test ["[0]" unit] ["_" property (.only Test)]]]] -- cgit v1.2.3