summaryrefslogtreecommitdiff
path: root/test/script/run.et
blob: 97f4dd8b8466715247c584e085660124ee44336b (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
module run

asset scripts:
    path: ../asset/run

asset scripts_success:
    path: ../asset/run-success

asset scripts_fail:
    path: ../asset/run-fail


test TrivialRun:
    spawn as p 
    with p:
        send "load ${scripts.path}/trivial.et"
        expect /load-done/

        send "run AlwaysSucceeds"
        local:
            expect /run-test-result AlwaysSucceeds (.*)/ capture result
            guard (result == "done")
            expect /run-done/

        send "run AlwaysFails"
        local:
            expect /match-fail .*/
            expect /run-test-result AlwaysFails (.*)/ capture result
            guard (result == "failed")
            expect /run-done/


test SimpleRun:
    let should_succeed = [ "bool", "command-flush", "command-ignore" ]
    let should_fail = [ "bool", "command-ignore" ]
    spawn as p

    with p:
        for file in should_succeed:
            send "load ${scripts_success.path}/$file.et"
            local:
                expect /(load-.*)/ capture done
                guard (done == "load-done")
            flush

            send "run Test"
            local:
                expect /run-test-result Test (.*)/ capture result
                guard (result == "done")
                expect /run-done/
            flush

        for file in should_fail:
            send "load ${scripts_fail.path}/$file.et"
            local:
                expect /(load-.*)/ capture done
                guard (done == "load-done")
            flush

            send "run Test"
            local:
                expect /run-test-result Test (.*)/ capture result
                guard (result == "failed")
                expect /run-done/
            flush


test RunConfig:
    node n
    local:
        shell on n:
            cp ${scripts.path}/erebos-tester.yaml .
            mkdir tools
            cp ${scripts.path}/tools/echo.sh ./tools/tool
            mkdir scripts
            cp ${scripts.path}/trivial.et ./scripts/
            cp ${scripts.path}/echo.et ./scripts/

    spawn as p on n

    with p:
        send "load-config"
        expect /load-config-done/
        send "run-all"
        expect /run-test-result AlwaysSucceeds done/
        expect /run-test-result AlwaysFails failed/
        expect /child-stdin p abcdef/
        expect /child-stdout p abcdef/
        expect /match p abcdef/
        expect /run-test-result ExpectEcho done/
        expect /run-all-done/


test GetSysInfo:
    node n
    local:
        shell on n:
            cp ${scripts.path}/erebos-tester.yaml .
            mkdir tools
            cp ${scripts.path}/tools/sysinfo.sh ./tools/tool
            mkdir scripts
            cp ${scripts.path}/sysinfo.et ./scripts/

    spawn as p on n

    with p:
        send "load-config"
        expect /load-config-done/
        send "run SysInfo"
        expect /run-done/


test CallStack:
    spawn as p
    with p:
        send "load ${scripts.path}/callstack.et"
        expect /load-done/

        send "run AG"
        expect /match-fail guard failed/
        expect /match-fail-line .*\/callstack.et:3:5: .*/
        expect /match-fail-var x 1/
        local:
            expect /(match-fail-.*)/ capture done
            guard (done == "match-fail-done")
        local:
            expect /run-test-result AG (.*)/ capture result
            guard (result == "failed")
            expect /run-done/
        flush

        send "run AE"
        expect /match-fail expect failed/
        expect /match-fail-line .*\/callstack.et:8:5: .*/
        expect /match-fail-var x 2/
        local:
            expect /(match-fail-.*)/ capture done
            guard (done == "match-fail-done")
        local:
            expect /run-test-result AE (.*)/ capture result
            guard (result == "failed")
            expect /run-done/
        flush

        send "run BG"
        expect /match-fail guard failed/
        expect /match-fail-line .*\/callstack.et:12:5: .*/
        expect /match-fail-var x 1/
        expect /match-fail-line .*\/callstack.et:15:5: .*/
        local:
            expect /(match-fail-.*)/ capture done
            guard (done == "match-fail-done")
        local:
            expect /run-test-result BG (.*)/ capture result
            guard (result == "failed")
            expect /run-done/
        flush

        send "run CG"
        expect /match-fail guard failed/
        expect /match-fail-line .*\/callstack.et:19:5: .*/
        expect /match-fail-var x 3/
        expect /match-fail-var y 2/
        expect /match-fail-line .*\/callstack.et:23:5: .*/
        expect /match-fail-var z 3/
        local:
            expect /(match-fail-.*)/ capture done
            guard (done == "match-fail-done")
        local:
            expect /run-test-result CG (.*)/ capture result
            guard (result == "failed")
            expect /run-done/
        flush

        send "run BE"
        expect /match-fail expect failed/
        expect /match-fail-line .*\/callstack.et:27:5: .*/
        expect /match-fail-var x 1/
        expect /match-fail-line .*\/callstack.et:31:5: .*/
        expect /match-fail-var p <process:p#[0-9]+>/
        local:
            expect /(match-fail-.*)/ capture done
            guard (done == "match-fail-done")
        local:
            expect /run-test-result BE (.*)/ capture result
            guard (result == "failed")
            expect /run-done/
        flush

        send "run CE"
        expect /match-fail expect failed/
        expect /match-fail-line .*\/callstack.et:36:5: .*/
        expect /match-fail-var x 3/
        expect /match-fail-var y 2/
        expect /match-fail-line .*\/callstack.et:41:5: .*/
        expect /match-fail-var p <process:p#[0-9]+>/
        expect /match-fail-var z 3/
        local:
            expect /(match-fail-.*)/ capture done
            guard (done == "match-fail-done")
        local:
            expect /run-test-result CE (.*)/ capture result
            guard (result == "failed")
            expect /run-done/
        flush


test RunTag:
    spawn as p
    with p:
        send "load ${scripts.path}/tags.et"
        local:
            expect /(load-.*)/ capture done
            guard (done == "load-done")
        flush

        send "run A"
        local:
            expect /run-test-result A1 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result A2 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-(.*)/ capture done
            guard (done == "done")

        send "run B C"
        local:
            expect /run-test-result B1 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result B2 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result C1 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result C2 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result BC (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-(.*)/ capture done
            guard (done == "done")


test RunTagExclude:
    spawn as p
    with p:
        send "load ${scripts.path}/tags.et"
        local:
            expect /(load-.*)/ capture done
            guard (done == "load-done")
        flush

        send "run * ^A ^C ^T2 ^B1"
        local:
            expect /run-test-result T1 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result B2 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-(.*)/ capture done
            guard (done == "done")

        send "run T1 B1 A C ^B ^A1"
        local:
            expect /run-test-result T1 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result A2 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result C1 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-test-result C2 (.*)/ capture result
            guard (result == "done")
        local:
            expect /run-(.*)/ capture done
            guard (done == "done")