aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/command/build.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-17 22:48:54 -0400
committerEduardo Julian2021-07-17 22:48:54 -0400
commit442d1557b879a8a4bd76f441f72a17bfb71cf05f (patch)
tree7726138a487b3d64081c2cfdf99a564cf2b6ed7b /stdlib/source/test/aedifex/command/build.lux
parent2c99b4515447315d76a8dc203a2dbcafc09506ea (diff)
Now allowing compilers to generate custom-named outputs.
Diffstat (limited to 'stdlib/source/test/aedifex/command/build.lux')
-rw-r--r--stdlib/source/test/aedifex/command/build.lux68
1 files changed, 68 insertions, 0 deletions
diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux
index 1292c232f..4b0960d32 100644
--- a/stdlib/source/test/aedifex/command/build.lux
+++ b/stdlib/source/test/aedifex/command/build.lux
@@ -5,6 +5,7 @@
[abstract
[monad (#+ do)]]
[control
+ [pipe (#+ case>)]
[io (#+ IO)]
["." try]
["." exception]
@@ -72,6 +73,38 @@
(def: (on_await state)
(#try.Success [state shell.error]))))))))
+(def: #export (reader_shell error?)
+ (-> Bit (-> (List Text) (Shell IO)))
+ (shell.mock
+ (function (_ [actual_environment actual_working_directory actual_command actual_arguments])
+ (#try.Success
+ (: (shell.Mock (List Text))
+ (implementation
+ (def: (on_read state)
+ (if error?
+ (exception.throw shell.no_more_output [])
+ (case state
+ (#.Cons head tail)
+ (#try.Success [tail head])
+
+ #.Nil
+ (exception.throw shell.no_more_output []))))
+ (def: (on_error state)
+ (if error?
+ (case state
+ (#.Cons head tail)
+ (#try.Success [tail head])
+
+ #.Nil
+ (exception.throw shell.no_more_output []))
+ (exception.throw shell.no_more_output [])))
+ (def: (on_write input state)
+ (#try.Failure "on_write"))
+ (def: (on_destroy state)
+ (#try.Failure "on_destroy"))
+ (def: (on_await state)
+ (#try.Success [state shell.error]))))))))
+
(def: compiler
(Random Dependency)
(do random.monad
@@ -181,4 +214,39 @@
(text\= /.failure end))))]
(_.cover' [/.failure]
(try.default false verdict)))))
+ (do !
+ [expected/0 (random.ascii/alpha 5)
+ expected/1 (random.ascii/alpha 5)
+ expected/2 (random.ascii/alpha 5)]
+ (`` ($_ _.and
+ (~~ (template [<error?> <log!>]
+ [(let [console (@version.echo "")
+ shell (|> (list expected/0 expected/1 expected/2)
+ (..reader_shell <error?>)
+ shell.async)]
+ (wrap (do {! promise.monad}
+ [verdict (do ///action.monad
+ [process (shell [environment.empty working_directory "" (list "")])
+ _ (<log!> console process)
+ actual/0 (\ console read_line [])
+ actual/1 (\ console read_line [])
+ actual/2 (\ console read_line [])
+ end! (|> (\ console read_line [])
+ (\ ! map (|>> (case> (#try.Failure error)
+ true
+
+ (#try.Success _)
+ false)
+ #try.Success)))]
+ (wrap (and (text\= expected/0 actual/0)
+ (text\= expected/1 actual/1)
+ (text\= expected/2 actual/2)
+ end!)))]
+ (_.cover' [<log!>]
+ (try.default false verdict)))))]
+
+ [#0 /.log_output!]
+ [#1 /.log_error!]
+ ))
+ )))
))))