aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/command/auto.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-06 21:34:21 -0400
committerEduardo Julian2021-07-06 21:34:21 -0400
commit2b909032e7a0bd10cd7db52067d2fb701bfa95e5 (patch)
tree0e2aaef228f80f3336715327f7f34065c309de22 /stdlib/source/test/aedifex/command/auto.lux
parent5cf4efa861075f8276f43a2516f5beacaf610b44 (diff)
Simplified the API for file-system operations.
Diffstat (limited to 'stdlib/source/test/aedifex/command/auto.lux')
-rw-r--r--stdlib/source/test/aedifex/command/auto.lux93
1 files changed, 46 insertions, 47 deletions
diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux
index 0808c7d21..effc80871 100644
--- a/stdlib/source/test/aedifex/command/auto.lux
+++ b/stdlib/source/test/aedifex/command/auto.lux
@@ -4,51 +4,47 @@
[abstract
[monad (#+ do)]]
[control
+ [pipe (#+ case>)]
["." try]
[parser
- ["." environment (#+ Environment)]]
+ ["." environment]]
[concurrency
["." atom (#+ Atom)]
["." promise (#+ Promise)]]]
[data
+ ["." binary]
["." text
["%" format (#+ format)]
[encoding
["." utf8]]]
[collection
- ["." dictionary]
- ["." set]
- ["." list ("#\." functor)]]]
+ ["." set]]]
[math
- ["." random (#+ Random)]
+ ["." random]
[number
["n" nat]]]
+ [time
+ ["." instant]]
[world
[console (#+ Console)]
["." shell (#+ Shell)]
["." program (#+ Program)]
- ["." file (#+ Path File)
+ ["." file
["." watch]]]]
["." // #_
- ["@." version]
- ["@." build]
- ["$/#" // #_
- ["#." package]]]
+ ["$." version]
+ ["$." build]]
{#program
["." /
- ["/#" // #_
- ["#." build]
- ["/#" // #_
- [command (#+ Command)]
- ["#" profile (#+ Profile)]
- ["#." action]
- ["#." artifact
- ["#/." type]]
- ["#." dependency
- ["#/." resolution (#+ Resolution)]]]]]})
+ ["//#" /// #_
+ [command (#+ Command)]
+ ["#" profile (#+ Profile)]
+ ["#." action]
+ [dependency
+ [resolution (#+ Resolution)]]]]})
-(def: (command expected_runs end_signal dummy_file)
- (-> Nat Text (File Promise)
+(def: (command expected_runs end_signal fs dummy_file)
+ (-> Nat Text (file.System Promise) file.Path
[(Atom Nat)
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any))])
(let [@runs (: (Atom Nat)
@@ -60,18 +56,18 @@
(if (n.= expected_runs actual_runs)
(wrap (#try.Failure end_signal))
(do (try.with !)
- [_ (\ dummy_file over_write (\ utf8.codec encode (%.nat actual_runs)))]
- (do !
- [_ (promise.future (atom.write actual_runs @runs))]
- (wrap (#try.Success [])))))))]))
+ [_ (\ fs write (\ utf8.codec encode (%.nat actual_runs)) dummy_file)]
+ (\ fs modify
+ (|> actual_runs .int instant.from_millis)
+ dummy_file)))))]))
(def: #export test
Test
(<| (_.covering /._)
(do {! random.monad}
- [#let [/ (\ file.default separator)
+ [end_signal (random.ascii/alpha 5)
+ #let [/ (\ file.default separator)
[fs watcher] (watch.mock /)]
- end_signal (random.ascii/alpha 5)
program (random.ascii/alpha 5)
target (random.ascii/alpha 5)
@@ -93,30 +89,33 @@
expected_runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat)
dummy_path (\ ! map (|>> (format source /)) (random.ascii/alpha 5))
- resolution @build.resolution]
+ resolution $build.resolution]
($_ _.and
(wrap (do promise.monad
[verdict (do ///action.monad
- [_ (\ fs create_directory source)
- dummy_file (\ fs create_file dummy_path)
- #let [[@runs command] (..command expected_runs end_signal dummy_file)]
+ [_ (\ fs make_directory source)
+ _ (\ fs write (binary.create 0) dummy_path)
+ #let [[@runs command] (..command expected_runs end_signal fs dummy_path)]
_ (\ watcher poll [])]
- (do promise.monad
- [outcome ((/.do! 1 watcher command)
- (@version.echo "")
- (program.async (program.mock environment.empty home working_directory))
- fs
- (shell.async (@build.good_shell []))
- resolution
- profile)
- actual_runs (promise.future (atom.read @runs))]
- (wrap (#try.Success (and (n.= expected_runs actual_runs)
- (case outcome
- (#try.Failure error)
- (is? end_signal error)
+ (do {! promise.monad}
+ [no_dangling_process! (|> profile
+ ((/.do! 1 watcher command)
+ ($version.echo "")
+ (program.async (program.mock environment.empty home working_directory))
+ fs
+ (shell.async ($build.good_shell []))
+ resolution)
+ (\ ! map (|>> (case> (#try.Failure error)
+ (is? end_signal error)
- (#try.Success _)
- false))))))]
+ (#try.Success _)
+ false))))
+ correct_number_of_runs! (|> @runs
+ atom.read
+ promise.future
+ (\ ! map (n.= expected_runs)))]
+ (wrap (#try.Success (and correct_number_of_runs!
+ no_dangling_process!)))))]
(_.cover' [/.do!]
(try.default false verdict))))
))))