aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/test.lux
blob: 3b5afaabfb4fe422a6bedfe94d224afe304982f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(.module:
  [lux (#- Name)
   [abstract
    [monad (#+ do)]]
   [control
    [concurrency
     ["." promise (#+ Promise) ("#\." monad)]]
    [security
     ["!" capability]]
    [parser
     [environment (#+ Environment)]]]
   [data
    [text
     ["%" format (#+ format)]]
    [number
     ["i" int]]]
   [world
    ["." file]
    ["." shell (#+ Shell)]
    ["." console (#+ Console)]]]
  ["." // #_
   ["#." build]
   ["/#" // #_
    ["#." action]
    ["#." command (#+ Command)]
    ["#." runtime]
    [dependency
     [resolution (#+ Resolution)]]]])

(def: #export start "[TEST STARTED]")
(def: #export success "[TEST ENDED]")
(def: #export failure "[TEST FAILED]")

(def: #export (do! console environment fs shell resolution profile)
  (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command Any))
  (do ///action.monad
    [[compiler program] (//build.do! console environment fs shell resolution profile)
     working-directory (promise\wrap (//build.working-directory environment))
     _ (console.write-line ..start console)
     process (!.use (\ shell execute)
                    [environment
                     working-directory
                     (case compiler
                       (#//build.JVM artifact) (///runtime.java program)
                       (#//build.JS artifact) (///runtime.node program))
                     (list)])
     exit (!.use (\ process await) [])
     _ (console.write-line (if (i.= shell.normal exit)
                             ..success
                             ..failure)
                           console)]
    (wrap [])))