(.module: [lux #* ["_" test (#+ Test)] [abstract [monad (#+ do)]] [control ["." try] [concurrency ["." promise]] [parser ["." environment]] [security ["!" capability]]] [data ["." text ("#\." equivalence)] [collection ["." dictionary]]] [math ["." random]] [world ["." file] ["." shell] ["." program]]] ["." // #_ ["@." version] ["@." build] ["$/#" // #_ ["#." package]]] {#program ["." / ["/#" // #_ ["#." build] ["/#" // #_ ["#" profile (#+ Profile)] ["#." action] ["#." artifact ["#/." type]] ["#." dependency ["#/." resolution]]]]]}) (def: #export test Test (<| (_.covering /._) (do {! random.monad} [program (random.ascii/alpha 5) target (random.ascii/alpha 5) home (random.ascii/alpha 5) working_directory (random.ascii/alpha 5) #let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) (set@ #///.target (#.Some target))) with_program (: (-> Profile Profile) (set@ #///.program (#.Some program))) profile (|> empty_profile with_program with_target)] resolution @build.resolution] ($_ _.and (let [fs (file.mock (\ file.default separator)) console (@version.echo "")] (wrap (do promise.monad [verdict (do ///action.monad [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs (@build.good_shell []) resolution profile) build_start (!.use (\ console read_line) []) build_end (!.use (\ console read_line) []) test_start (!.use (\ console read_line) []) test_end (!.use (\ console read_line) [])] (wrap (and (and (text\= //build.start build_start) (text\= //build.success build_end)) (and (text\= /.start test_start) (text\= /.success test_end)))))] (_.cover' [/.do! /.start /.success] (try.default false verdict))))) (let [fs (file.mock (\ file.default separator)) console (@version.echo "")] (wrap (do promise.monad [verdict (do ///action.monad [#let [bad_shell (shell.mock (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) (structure (def: (on_read state) (#try.Failure "on_read")) (def: (on_error state) (#try.Failure "on_error")) (def: (on_write input state) (#try.Failure "on_write")) (def: (on_destroy state) (#try.Failure "on_destroy")) (def: (on_await state) (#try.Success [state (if (text.ends_with? " build" actual_command) shell.normal shell.error)])))))) [])] _ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs bad_shell resolution profile) build_start (!.use (\ console read_line) []) build_end (!.use (\ console read_line) []) test_start (!.use (\ console read_line) []) test_end (!.use (\ console read_line) [])] (wrap (and (and (text\= //build.start build_start) (text\= //build.success build_end)) (and (text\= /.start test_start) (text\= /.failure test_end)))))] (_.cover' [/.failure] (try.default false verdict))))) ))))