blob: f1c0c2de126c65d76dfc1bc52adc751d7ad2bdef (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
(.module:
[library
[lux #*
["_" test (#+ Test)]
[abstract
["." monad (#+ do)]]
[control
["." try (#+ Try) ("#\." functor)]
["." exception]
[concurrency
["." async (#+ Async)]]
[parser
["." environment]]]
[data
["." binary]
["." text ("#\." equivalence)
["%" format (#+ format)]]
[collection
["." set (#+ Set)]]]
[math
["." random]]
[world
["." file]
["." program (#+ Program)]]]]
[//
["$." version]
[//
["$." profile]
["$." artifact]]]
[\\program
["." /
["/#" // #_
["/#" // #_
["#" profile]
["#." action (#+ Action)]
["#." local]
["#." artifact
["#/." extension]]
["#." repository #_
["#/." local]]]]]])
(def: .public (make_sources! fs sources)
(-> (file.System Async) (Set file.Path) (Action (List Any)))
(let [/ (\ fs separator)
! ///action.monad]
(|> sources
set.list
(monad.map ! (function (_ head)
(do !
[_ (: (Async (Try Any))
(file.make_directories async.monad fs head))]
(: (Async (Try Any))
(file.make_file async.monad fs (binary.empty 0) (format head / head ".lux")))))))))
(def: (execute! program fs sample)
(-> (Program Async) (file.System Async) ///.Profile (Async (Try Text)))
(do ///action.monad
[.let [console ($version.echo "")]
_ (..make_sources! fs (value@ #///.sources sample))
_ (/.do! console fs (///repository/local.repository program fs) sample)]
(\ console read_line [])))
(def: .public test
Test
(<| (_.covering /._)
(do {! random.monad}
[identity $artifact.random
sample (\ ! map (with@ #///.identity (#.Some identity))
$profile.random)
home (random.ascii/alpha 5)
working_directory (random.ascii/alpha 5)
.let [/ (\ file.default separator)]]
($_ _.and
(in (do {! async.monad}
[.let [fs (file.mock /)
program (program.async (program.mock environment.empty home working_directory))
artifact_path (///local.uri (value@ #///artifact.version identity) identity)
library_path (format artifact_path ///artifact/extension.lux_library)
pom_path (format artifact_path ///artifact/extension.pom)]
verdict (do {! ///action.monad}
[succeeded! (\ ! map (text\= /.success)
(..execute! program fs sample))
library_exists! (|> library_path
(format home /)
(\ fs file?)
(\ async.monad map (|>> #try.Success)))
pom_exists! (|> pom_path
(format home /)
(\ fs file?)
(\ async.monad map (|>> #try.Success)))]
(in (and succeeded!
library_exists!
pom_exists!)))]
(_.cover' [/.do! /.success]
(try.else false verdict))))
(in (do {! async.monad}
[.let [fs (file.mock /)
program (program.async (program.mock environment.empty home working_directory))]
logging (..execute! program fs (with@ #///.identity #.None sample))]
(_.cover' [/.failure]
(|> logging
(try\map (text\= /.failure))
(try.else false)))))
))))
|