aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/test.lux
blob: a7279c5ec5c829eead291c21cef4612d61bdc460 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(.module:
  [library
   [lux (#- Name)
    [abstract
     [monad (#+ do)]]
    [control
     [concurrency
      ["." async (#+ Async) ("#\." monad)]]]
    [math
     [number
      ["i" int]]]
    [world
     ["." program (#+ Program)]
     ["." file]
     ["." shell (#+ Exit Shell)]
     ["." console (#+ Console)]]]]
  ["." // #_
   ["#." build]
   ["/#" // #_
    ["#" profile]
    ["#." action]
    ["#." command (#+ Command)]
    ["#." runtime]
    [dependency
     [resolution (#+ Resolution)]]]])

(def: .public start "[TEST STARTED]")
(def: .public success "[TEST ENDED]")
(def: .public failure "[TEST FAILED]")

(def: .public (do! console program fs shell resolution profile)
  (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Any]))
  (do async.monad
    [environment (program.environment async.monad program)
     .let [working_directory (\ program directory)]]
    (do {! ///action.monad}
      [.let [home (\ program home)]
       [build_exit compiler program] (//build.do! console program fs shell resolution
                                                  (set@ #///.program (get@ #///.test profile) profile))]
      (if (i.= shell.normal build_exit)
        (do !
          [_ (console.write_line ..start console)
           .let [host_dependencies (//build.host_dependencies fs home resolution)
                 [test_command test_parameters] (case compiler
                                                  (#//build.JVM dependency)
                                                  (|> program
                                                      (///runtime.for (get@ #///.java profile))
                                                      (//build.with_jvm_class_path host_dependencies))
                                                  
                                                  (^template [<tag> <runtime>]
                                                    [(<tag> artifact)
                                                     (///runtime.for (get@ <runtime> profile)
                                                                     program)])
                                                  ([#//build.JVM #///.java]
                                                   [#//build.JS #///.js]
                                                   [#//build.Python #///.python]
                                                   [#//build.Lua #///.lua]
                                                   [#//build.Ruby #///.ruby]))]
           process (\ shell execute [environment
                                     working_directory
                                     test_command
                                     test_parameters])
           _ (//build.log_output! console process)
           _ (//build.log_error! console process)
           exit (\ process await [])
           _ (console.write_line (if (i.= shell.normal exit)
                                   ..success
                                   ..failure)
                                 console)]
          (in [exit []]))
        (in [build_exit []])))))