-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtests.dhall
382 lines (369 loc) · 15.4 KB
/
tests.dhall
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
let Meta = ./tests/Meta/package.dhall
let Replica =
env:REPLICA_DHALL
? https://raw.githubusercontent.com/ReplicaTest/replica-dhall/main/package.dhall
sha256:e89a5d8a50bf5551f1012d7c627ab6d1fd278148a7341682247b2e024fcf90d4
let Test = Replica.Test
let Status = Replica.Status
let Expectation = Replica.Expectation
let runTestsJSON = Meta.Run ([] : List Text) [ "tests.json" ]
let basicTests
: Replica.Type
= Replica.Suite
"basic"
( toMap
{ simplest_success = Test::{
, command = "true"
, description = Some
"A call to 'true' must succeed with no output"
}
, test_success = Test.Success::{
, command = "true"
, description = Some "Check the success exit code"
}
, test_failure = Test.Failure::{
, command = "false"
, description = Some "Test a non null exit code"
}
}
)
let templateTests
: Replica.Type
= Replica.Suite
"template"
( toMap
{ new_json_template =
(Meta.Run ([] : List Text) [ "generated.json" ])
with workingDir = Some "tests/replica/new"
with description = Some "generated json template should succeed"
with status = Status.Success
with beforeTest =
[ "${Meta.default.executable} new generated.json" ]
with afterTest = [ "rm -rf .replica", "rm -f generated.json" ]
with tags = [ "meta" ]
, new_json_empty_template =
(Meta.Run ([] : List Text) [ "generated.json" ])
with workingDir = Some "tests/replica/new"
with description = Some
"generated empty json template should succeed"
with status = Status.Success
with beforeTest =
[ "${Meta.default.executable} new -S generated.json" ]
with afterTest = [ "rm -rf .replica", "rm -f generated.json" ]
with tags = [ "meta" ]
, new_dhall_template =
(Meta.Run ([] : List Text) [ "generated.json" ])
with workingDir = Some "tests/replica/new"
with description = Some "generated dhall template should succeed"
with require = [ "new_json_template" ]
with status = Status.Success
with beforeTest =
[ "${Meta.default.executable} new generated.dhall"
, "dhall-to-json --file generated.dhall --output generated.json"
]
with afterTest =
[ "rm -rf .replica"
, "rm -f generated.json"
, "rm -f generated.dhall"
]
with tags = [ "meta", "online" ]
, new_dhall_empty_template =
(Meta.Run ([] : List Text) [ "generated.json" ])
with workingDir = Some "tests/replica/new"
with description = Some
"generated empty dhall template should succeed"
with require = [ "new_json_empty_template" ]
with status = Status.Success
with beforeTest =
[ "${Meta.default.executable} new -S generated.dhall"
, "dhall-to-json --file generated.dhall --output generated.json"
]
with afterTest =
[ "rm -rf .replica"
, "rm -f generated.json"
, "rm -f generated.dhall"
]
with tags = [ "meta", "online" ]
}
)
let filterTests
: Replica.Type
= Replica.Suite
"filter"
( toMap
{ testOnly =
(Meta.Run [ "--only one" ] [ "tests.json" ])
with workingDir = Some "tests/replica/two"
with description = Some "Test tests filtering with \"--only\""
with status = Status.Success
with tags = [ "filter", "meta", "run" ]
, testExclude =
(Meta.Run [ "--exclude one" ] [ "tests.json" ])
with workingDir = Some "./tests/replica/two"
with description = Some "Test tests filtering with \"--exclude\""
with status = Status.Success
with tags = [ "filter", "meta", "run" ]
, testTags =
(Meta.Run [ "--tags shiny" ] [ "tests.json" ])
with workingDir = Some "./tests/replica/two"
with description = Some "Test tests filtering with \"--tags\""
with status = Status.Success
with tags = [ "filter", "meta", "run" ]
, testExcludeTags =
(Meta.Run [ "--exclude-tags shiny" ] [ "tests.json" ])
with workingDir = Some "./tests/replica/two"
with description = Some
"Test tests filtering with \"--exclude-tags\""
with status = Status.Success
with tags = [ "filter", "meta", "run" ]
, testSkipExcludedDependencies =
(Meta.Run [ "--only depends_failed" ] [ "tests.json" ])
with workingDir = Some "tests/replica/require1"
with description = Some
"Dependencies that aren't included in the selected tests are ignored"
with status = Status.Success
with tags = [ "meta", "require", "run" ]
}
)
let skipExecutionTests
: Replica.Type
= Replica.Suite
"skip"
( toMap
{ testRequire =
runTestsJSON
with workingDir = Some "tests/replica/require1"
with description = Some
"A test failed when its requirements failed"
with status = Status.Failure
with tags = [ "meta", "require", "run" ]
, testPunitive =
(Meta.Run [ "--punitive" ] [ "tests.json" ])
with workingDir = Some "tests/replica/allButOne"
with description = Some "Test the punitive mode"
with status = Status.Failure
with tags = [ "punitive", "meta", "run" ]
, testPending =
runTestsJSON
with workingDir = Some "tests/replica/onePending"
with description = Some "Test that pending tests aren't processed"
with status = Status.Success
with tags = [ "pending", "meta", "run" ]
}
)
let configTests
: Replica.Type
= Replica.Suite
"config"
( toMap
{ custom_golden_dir =
(Meta.Run [ "--golden-dir golden" ] [ "tests.json" ])
with workingDir = Some "tests/replica/goldenDir"
with description = Some "test --goldenDir"
with status = Status.Success
with tags = [ "golden", "meta" ]
, custom_golden_dir_for_file =
(Meta.Run [ "--golden-dir golden" ] [ "tests.json" ])
with workingDir = Some "tests/replica/goldenDirFile"
with require = [ "file_expectation1" ]
with description = Some "test --goldenDir for files"
with status = Status.Success
with tags = [ "golden", "meta" ]
, local_config =
runTestsJSON
with workingDir = Some "tests/replica/localConfig"
with require = [ "custom_golden_dir" ]
with description = Some "test localConfig"
with status = Status.Success
with tags = [ "local", "meta" ]
}
)
let expectationsTests
: Replica.Type
= Replica.Suite
"expectations"
( toMap
{ test_given_expectation = Test.Success::{
, command = "echo \"Hello, world!\""
, description = Some
"We use the given expectation field if it exists"
, stdOut =
Expectation.Exact
''
Hello, world!
''
}
, no_golden_with_inlined_expectation =
(Meta.Run [ "--interactive" ] [ "tests.json" ])
with workingDir = Some "tests/replica/inlineMismatch"
with description = Some
"No interaction for mismatch when a value is given"
with require = [ "testOutputMismatch" ]
with status = Status.Failure
with tags = [ "meta", "run" ]
, start_success = Test.Success::{
, command = "echo \"Hello, World!\""
, description = Some "check a start expectation that succeeds"
, stdOut = Expectation::{ start = Some "Hello" }
, tags = [ "run", "partial", "start" ]
}
, start_fail =
runTestsJSON
with workingDir = Some "tests/replica/start_fail"
with description = Some "Check a start expectation that fails"
with status = Status.Failure
with tags = [ "run", "partial", "start" ]
, end_success = Test.Success::{
, command = "echo \"Hello, World!\""
, description = Some "Check an end expectation that succeeds"
, stdOut = Expectation::{
, end = Some
''
World!
''
}
, tags = [ "run", "partial", "end" ]
}
, end_fail =
runTestsJSON
with workingDir = Some "tests/replica/end_fail"
with description = Some "Check an end expectation that fails"
with status = Status.Failure
with tags = [ "run", "partial", "end" ]
, ordered_partial_expectation_match = Test.Success::{
, command = "echo \"Hello, World!\""
, description = Some "check a partial expectation that succeeds"
, stdOut = Expectation.Consecutive [ "Hello", "World" ]
, tags = [ "run", "partial" ]
}
, space_unsensitive_ordered_partial_expectation_match = Test.Success::{
, command = "echo \"Hello, World!\""
, spaceSensitive = False
, description = Some
"check a space unsensitive partial expectation that succeeds"
, stdOut = Expectation.Consecutive [ "Hello ", " World " ]
, tags = [ "run", "partial", "space" ]
}
, whatever_partial_expectation_match = Test.Success::{
, command = "echo \"Hello, World!\""
, description = Some
"check a not ordered partial expectation that succeeds"
, stdOut = Expectation.Contains [ "World", "Hello" ]
, tags = [ "run", "partial" ]
}
, ordered_partial_expectation_mismatch =
runTestsJSON
with workingDir = Some "tests/replica/orderedPartialFail"
with description = Some
"check an ordered partial expectation that fails"
with status = Status.Failure
with tags = [ "expectation", "run", "partial" ]
, file_expectation1 = Test.Success::{
, command = "echo \"test\" > tmp123456"
, description = Some "Check expectation on file"
, afterTest = [ "rm tmp123456" ]
, stdOut = Expectation.Ignored
, files = toMap { tmp123456 = Expectation.Golden }
, tags = [ "run", "file" ]
}
, file_expectation2 = Test.Success::{
, command = "echo \"test\" > tests/tmp123456"
, description = Some "Check expectation on file in a subdir"
, afterTest = [ "rm tests/tmp123456" ]
, stdOut = Expectation.Ignored
, files = toMap { tests/tmp123456 = Expectation.Golden }
, require = [ "file_expectation1" ]
, tags = [ "run", "file" ]
}
, error_expectation = Test.Success::{
, command = "echo \"test\" >&2"
, description = Some "Check expectation on error"
, stdOut = Expectation.Ignored
, stdErr = Expectation.Golden
, tags = [ "run", "error" ]
}
}
)
let tests
: Replica.Type
= basicTests
# templateTests
# filterTests
# skipExecutionTests
# expectationsTests
# configTests
in tests
# ./tests/parsing_errors.dhall
# ./tests/help.dhall
# ./tests/suite.dhall
# ./tests/idris.dhall
# [ { mapKey = "test space"
, mapValue = Test::{
, command = "echo \"Hello, World!\""
, description = Some "Test space in test name"
}
}
]
# toMap
{ testWorkingDir = Test.Success::{
, command = "./run.sh"
, description = Some
"Test that the workingDir parameter is taken into account"
, workingDir = Some "tests/basic"
}
, testOutput = Test.Success::{
, command = "echo \"Hello, World!\""
, description = Some "Output is checked correctly"
}
, testBefore = Test.Success::{
, command = "cat new.txt"
, description = Some "Test that beforeTest is executed correctly"
, workingDir = Some "tests/basic"
, beforeTest = [ "echo \"Fresh content\" > new.txt" ]
, afterTest = [ "rm new.txt" ]
, tags = [ "beforeTest" ]
}
, testReplica =
runTestsJSON
with workingDir = Some "tests/replica/empty"
with description = Some "Test that an empty test suite is passing"
with status = Status.Success
with tags = [ "meta", "run" ]
, testOutputMismatch =
runTestsJSON
with workingDir = Some "tests/replica/mismatch"
with description = Some "Content mismatch is printed on error"
with status = Status.Failure
with tags = [ "meta", "run" ]
, testBeforeTestFailImpact =
runTestsJSON
with workingDir = Some "tests/replica/beforeFailed"
with description = Some
"we should be able to fallback to a normal behaviour after a failure of beforeTest"
with tags = [ "beforeTest" ]
, testInput = Test.Success::{
, command = "cat"
, input = Some "hello, world"
, description = Some "pass input to the command"
}
, too_many_error =
runTestsJSON
with workingDir = Some "tests/replica/tooManyError"
with description = Some "test error code with too many error"
with status = Status.Exactly 128
with stdOut = Expectation.Ignored
with tags = [ "run", "error", "meta" ]
, multi_json =
(Meta.Run ([] : List Text) [ "tests1.json", "tests2.json" ])
with workingDir = Some "tests/replica/multi"
with description = Some "test several json files"
with status = Status.Success
with tags = [ "multi", "meta" ]
, multi_json_error =
(Meta.Run ([] : List Text) [ "tests1.json", "testsDup.json" ])
with workingDir = Some "tests/replica/multi"
with description = Some "test several json files"
with status = Status.Failure
with stdErr = Replica.Expectation.Golden
with tags = [ "multi", "meta" ]
}