blob: d970427d249ee548308c4c1cc102c3d134b59905 (
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
(.require
[library
[lux (.except)
[abstract
["[0]" monad (.only do)]]
[control
["[0]" maybe]
["[0]" try (.only Try)]
["[0]" exception]
[concurrency
["[0]" async (.only Async) (.use "[1]#[0]" monad)]]]
[data
["[0]" binary (.use "[1]#[0]" equivalence)
["[0]" \\format]]
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format (.only format)]
[encoding
["[0]" utf8]]]
["[0]" format
["[0]" tar]
["[0]" xml]]
[collection
["[0]" set]]]
[math
["[0]" random]]
[meta
[compiler
[meta
["[0]" export]]]]
[world
["[0]" file]
["[0]" shell (.only Process Shell)]
["[0]" environment
["program" / (.only Environment)]
["[1]" \\parser]]]
[test
["[0]" unit]
["_" property (.only Test)]]]]
["$" //
["[1][0]" install]
["[1][0]" version]
[//
["[1][0]" profile]
["[1][0]" repository]]]
[\\program
["[0]" / (.only)
["/[1]" //
["[1][0]" install]
["/[1]" //
["[1]" profile]
["[1][0]" action]
["[1][0]" pom]
["[1][0]" hash]
["[1][0]" repository (.only Repository)
["[1]/[0]" local]
["[1]/[0]" remote]]
["[1][0]" artifact (.only Artifact)
["[1]/[0]" extension]]]]]])
(def (shell fs)
(-> (file.System Async) (Shell Async))
(implementation
(def (execute [environment working_directory command arguments])
(do [! ///action.monad]
[files (of fs directory_files working_directory)
_ (monad.each !
(function (_ file)
(do !
[_ (is (Async (Try Any))
(file.copy async.monad fs
file
(format file ".asc")))]
(in [])))
files)]
(<| in
(is (Process Async))
(implementation
(def (read _)
(async#in (exception.except shell.no_more_output [])))
(def (fail _)
(async#in (exception.except shell.no_more_output [])))
(def (write input)
(async#in {try.#Failure "write"}))
(def (destroy _)
(async#in {try.#Failure "destroy"}))
(def (await _)
(in shell.error))))))))
(def (execute! program local remote fs artifact profile)
(-> (Environment Async) (Repository Async) (Repository Async) (file.System Async)
Artifact ///.Profile
(Async (Try [Text Text])))
(do ///action.monad
[.let [console ($version.echo "")]
_ ($install.make_sources! fs (the ///.#sources profile))
_ (/.do! program (..shell fs) console local remote fs artifact profile)
locally_installed! (of console read_line [])
deployed! (of console read_line [])]
(in [locally_installed! deployed!])))
(def .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[[artifact expected_pom profile]
(random.one (function (_ profile)
(do maybe.monad
[artifact (the ///.#identity profile)
expected_pom (try.maybe (///pom.write profile))]
(in [artifact expected_pom profile])))
$profile.random)
home (random.alphabetic 5)
working_directory (random.alphabetic 5)
.let [fs (file.mock (of file.default separator))
program (program.async (program.mock environment.empty home working_directory))
local (///repository/local.repository program fs)
remote (///repository.mock $repository.mock
$repository.empty)]]
(in (do [! async.monad]
[verdict (do [! ///action.monad]
[[locally_installed! deployed!] (..execute! program local remote fs artifact profile)
expected_library (|> profile
(the ///.#sources)
set.list
(export.library fs)
(of ! each (\\format.result tar.format)))
actual_pom (of remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact ///artifact/extension.pom))
actual_library (of remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact ///artifact/extension.lux_library))
actual_sha1 (of remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.sha1)))
actual_sha1 (of async.monad in
(do try.monad
[actual_sha1 (of utf8.codec decoded actual_sha1)]
(of ///hash.sha1_codec decoded actual_sha1)))
actual_md5 (of remote download (///repository/remote.uri (the ///artifact.#version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.md5)))
actual_md5 (of async.monad in
(do try.monad
[actual_md5 (of utf8.codec decoded actual_md5)]
(of ///hash.md5_codec decoded actual_md5)))
.let [succeeded!
(and (text#= //install.success locally_installed!)
(text#= /.success deployed!))
deployed_library!
(binary#= expected_library
actual_library)
deployed_pom!
(binary#= (|> expected_pom (of xml.codec encoded) (of utf8.codec encoded))
actual_pom)
deployed_sha1!
(of ///hash.equivalence =
(///hash.sha1 expected_library)
actual_sha1)
deployed_md5!
(of ///hash.equivalence =
(///hash.md5 expected_library)
actual_md5)]]
(in (and succeeded!
deployed_library!
deployed_pom!
deployed_sha1!
deployed_md5!)))]
(unit.coverage [/.do! /.success]
(try.else false verdict)))))))
|