1
- { stdenvNoCC , curl , python3 , pier , urbit } :
2
-
3
- stdenvNoCC . mkDerivation {
1
+ { click , pier , pkgs } :
2
+
3
+ let
4
+ poke = ''
5
+ =>
6
+ |%
7
+ ++ take-poke-ack
8
+ |= =wire
9
+ =/ m (strand ,?)
10
+ ^- form:m
11
+ |= tin=strand-input:strand
12
+ ?+ in.tin `[%skip ~]
13
+ ~ `[%wait ~]
14
+ [~ %agent * %poke-ack *]
15
+ ?. =(wire wire.u.in.tin)
16
+ `[%skip ~]
17
+ ?~ p.sign.u.in.tin
18
+ `[%done %.y]
19
+ `[%done %.n]
20
+ ==
21
+ ++ poke
22
+ |= [=dock =cage]
23
+ =/ m (strand ,?)
24
+ ^- form:m
25
+ =/ =card:agent:gall [%pass /poke %agent dock %poke cage]
26
+ ;< ~ bind:m (send-raw-card card)
27
+ (take-poke-ack /poke)
28
+ --
29
+
30
+ '' ;
31
+ testThread = dojoCommand :
32
+ pkgs . writeTextFile {
33
+ name = "${ dojoCommand } .hoon" ;
34
+ text = ''
35
+ ${ poke }
36
+ =/ m (strand ,vase)
37
+ ;< [=ship =desk =case] bind:m get-beak
38
+ ;< ok=? bind:m (poke [ship %dojo] %lens-command !>([%$ [%dojo '${ dojoCommand } '] [%output-file 'result/noun']]))
39
+ (pure:m !>(ok))
40
+ '' ;
41
+ } ;
42
+ appThread = generator : app :
43
+ pkgs . writeTextFile {
44
+ name = ":${ app } |${ generator } .hoon" ;
45
+ text = ''
46
+ ${ poke }
47
+ =/ m (strand ,vase)
48
+ ;< [=ship =desk =case] bind:m get-beak
49
+ ;< ok=? bind:m (poke [ship %dojo] %lens-command !>([%$ [%dojo '+${ app } /${ generator } '] [%app %${ app } ]]))
50
+ (pure:m !>(ok))
51
+ '' ;
52
+ } ;
53
+ pokeApp = hoon : mark : app :
54
+ pkgs . writeTextFile {
55
+ name = ":${ app } &${ mark } ${ hoon } .hoon" ;
56
+ text = ''
57
+ ${ poke }
58
+ =/ m (strand ,vase)
59
+ ;< [=ship =desk =case] bind:m get-beak
60
+ ;< ok=? bind:m (poke [ship %${ app } ] %${ mark } !>(${ hoon } ))
61
+ (pure:m !>(ok))
62
+ '' ;
63
+ } ;
64
+ in pkgs . stdenvNoCC . mkDerivation {
4
65
name = "test-urbit" ;
5
66
6
67
src = pier ;
7
68
8
69
phases = [ "unpackPhase" "buildPhase" "checkPhase" ] ;
9
70
10
- buildInputs = [ curl python3 ] ;
71
+ nativeBuildInputs = [ pkgs . netcat ] ;
11
72
12
73
unpackPhase = ''
13
74
cp -R $src ./pier
@@ -16,166 +77,48 @@ stdenvNoCC.mkDerivation {
16
77
17
78
buildPhase = ''
18
79
set -x
80
+ set -e
19
81
20
- ${ urbit } /bin/urbit -d ./pier 2> urbit-output
21
-
22
- # Sledge Hammer!
23
- # See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959
24
- python3 -c $'import os\n[os.set_blocking(i, True) for i in range(3)]\n'
25
-
26
- port=$(cat ./pier/.http.ports | grep loopback | tr -s ' ' '\n' | head -n 1)
27
-
28
- lensd() {
29
- # -f elided, this can hit server-side timeouts
30
- curl -s \
31
- --data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
32
- "http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
33
- }
34
-
35
- lensa() {
36
- # -f elided, this can hit server-side timeouts
37
- curl -s \
38
- --data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
39
- "http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
40
- }
41
-
42
- tail -F urbit-output >&2 &
43
-
44
- tailproc=$!
45
-
46
- cleanup () {
47
- kill $(cat ./pier/.vere.lock) || true
48
- kill "$tailproc" 2>/dev/null || true
49
-
50
- set +x
51
- }
52
-
53
- trap cleanup EXIT
54
-
55
- # measure initial memory usage
56
- #
57
- lensd '~& ~ ~& %init-mass-start ~'
58
- lensa hood '+hood/mass'
59
- lensd '~& ~ ~& %init-mass-end ~'
60
-
61
- # run the unit tests
62
- #
63
- lensd '~& ~ ~& %test-unit-start ~'
64
- lensd '-test %/tests ~'
65
- lensd '~& ~ ~& %test-unit-end ~'
66
-
67
- # use the :test app to build all agents, generators, and marks
68
- #
69
- lensa hood '+hood/start %test'
70
-
71
- lensd '~& ~ ~& %test-agents-start ~'
72
- lensa test '%agents'
73
- lensd '~& ~ ~& %test-agents-end ~'
82
+ ${ pkgs . urbit } /bin/urbit -d ./pier 1>&2 2> $out
74
83
75
- lensd '~& ~ ~& %test-generators-start ~'
76
- lensa test '%generators'
77
- lensd '~& ~ ~& %test-generators-end ~'
84
+ tail -F $out >&2 &
85
+
86
+ ${ click } -k -p -i ${ appThread "mass" "hood" } ./pier
78
87
79
- lensd '~& ~ ~& %test-marks-start ~'
80
- lensa test '%marks'
81
- lensd '~& ~ ~& %test-marks-end ~'
88
+ sleep 2
82
89
83
- # measure memory usage post tests
84
- #
85
- lensd '~& ~ ~& %test-mass-start ~'
86
- lensa hood '+hood/mass'
87
- lensd '~& ~ ~& %test-mass-end ~'
90
+ ${ click } -k -p -i ${ testThread "-test %/tests ~" } ./pier
88
91
89
- # defragment the loom
90
- #
91
- lensd '~& ~ ~& %pack-start ~'
92
- lensa hood '+hood/pack'
93
- lensd '~& ~ ~& %pack-end ~'
92
+ ${ click } -k -p -i ${ pokeApp "%agents" "noun" "test" } ./pier
93
+ ${ click } -k -p -i ${ pokeApp "%generators" "noun" "test" } ./pier
94
+ ${ click } -k -p -i ${ pokeApp "%marks" "noun" "test" } ./pier
94
95
95
- # reclaim space within arvo
96
- #
97
- lensd '~& ~ ~& %trim-start ~'
98
- lensa hood '+hood/trim'
99
- lensd '~& ~ ~& %trim-end ~'
96
+ # The rest of the commands fail for unknown reasons.
100
97
101
- # measure memory usage pre |meld
102
- #
103
- lensd '~& ~ ~& %trim-mass-start ~'
104
- lensa hood '+hood/mass'
105
- lensd '~& ~ ~& %trim-mass-end ~'
98
+ # ${ click } -k -p -i ${ appThread "mass" "hood" } ./pier
99
+ # sleep 2
106
100
107
- # globally deduplicate
108
- #
109
- lensd '~& ~ ~& %meld-start ~'
110
- lensa hood '+hood/meld'
111
- lensd '~& ~ ~& %meld-end ~'
101
+ # ${ click } -k -p -i ${ pokeApp "~" "helm-pack" "hood" } ./pier
112
102
113
- # measure memory usage post |meld
114
- #
115
- lensd '~& ~ ~& %meld-mass-start ~'
116
- lensa hood '+hood/mass'
117
- lensd '~& ~ ~& %meld-mass-end ~'
103
+ # ${ click } -k -p -i ${ appThread "trim" "hood" } ./pier
118
104
119
- lensa hood '+ hood/exit'
105
+ # ${ click } -k -p -i ${ appThread "mass" " hood" } ./pier
120
106
121
- cleanup
107
+ # ${ click } -k -p -i ${ appThread "meld" "hood" } ./pier
122
108
123
- # Collect output
124
- cp urbit-output test-output-unit
125
- cp urbit-output test-output-agents
126
- cp urbit-output test-output-generators
127
- cp urbit-output test-output-marks
128
-
129
- sed -i '0,/test-unit-start/d' test-output-unit
130
- sed -i '/test-unit-end/,$d' test-output-unit
109
+ # sleep 60
131
110
132
- sed -i '0,/test-agents-start/d' test-output-agents
133
- sed -i '/test-agents-end/,$d' test-output-agents
111
+ # ${ click } -k -p -i ${ appThread "mass" "hood" } ./pier
134
112
135
- sed -i '0,/test-generators-start/d' test-output-generators
136
- sed -i '/test-generators-end/,$d' test-output-generators
137
-
138
- sed -i '0,/test-marks-start/d' test-output-marks
139
- sed -i '/test-marks-end/,$d' test-output-marks
140
-
141
- mkdir -p $out
142
-
143
- cp test-output-* $out/
113
+ # ${ click } -k -p -i ${ appThread "exit" "hood" } ./pier
144
114
145
115
set +x
146
116
'' ;
147
117
148
118
checkPhase = ''
149
- hdr () {
150
- echo =====$(sed 's/./=/g' <<< "$1")=====
151
- echo ==== $1 ====
152
- echo =====$(sed 's/./=/g' <<< "$1")=====
153
- }
154
-
155
- for f in $(find "$out/" -type f); do
156
- hdr "$(basename $f)"
157
- cat "$f"
158
- done
159
-
160
- fail=0
161
-
162
- for f in $(find "$out/" -type f); do
163
- if egrep "((FAILED|CRASHED)|warn:) " $f >/dev/null; then
164
- if [[ $fail -eq 0 ]]; then
165
- hdr "Test Failures"
166
- fi
167
-
168
- echo "ERROR Test failure in $(basename $f)"
169
-
170
- ((fail++))
171
- fi
172
- done
173
-
174
- if [[ $fail -eq 0 ]]; then
175
- hdr "Success"
119
+ if egrep "((FAILED|CRASHED|Failed)|warn:)" $out >/dev/null; then
120
+ exit 1
176
121
fi
177
-
178
- exit "$fail"
179
122
'' ;
180
123
181
124
doCheck = true ;
0 commit comments