Skip to content

Commit 6a355a4

Browse files
authored
nim: unbreak CI; testament: add allowedFailure logic for tests that may fail but should still run (#17513)
1 parent b77a420 commit 6a355a4

File tree

3 files changed

+40
-30
lines changed

3 files changed

+40
-30
lines changed

testament/categories.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,10 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string) =
448448
(outp, status) = execCmdEx(cmd, workingDir = workingDir2)
449449
status == QuitSuccess
450450
if not ok:
451-
addResult(r, test, targetC, "", cmd & "\n" & outp, reFailed)
451+
if pkg.allowFailure:
452+
inc r.passed
453+
inc r.failedButAllowed
454+
addResult(r, test, targetC, "", cmd & "\n" & outp, reFailed, allowFailure = pkg.allowFailure)
452455
continue
453456
outp
454457

@@ -461,7 +464,7 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string) =
461464
discard tryCommand("nimble install --depsOnly -y", maxRetries = 3)
462465
discard tryCommand(pkg.cmd, reFailed = reBuildFailed)
463466
inc r.passed
464-
r.addResult(test, targetC, "", "", reSuccess)
467+
r.addResult(test, targetC, "", "", reSuccess, allowFailure = pkg.allowFailure)
465468

466469
errors = r.total - r.passed
467470
if errors == 0:

testament/important_packages.nim

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,40 @@ When this is the case, a workaround is to test this package here by adding `--pa
2222
type NimblePackage* = object
2323
name*, cmd*, url*: string
2424
useHead*: bool
25+
allowFailure*: bool
26+
## When true, we still run the test but the test is allowed to fail.
27+
## This is useful for packages that currently fail but that we still want to
28+
## run in CI, e.g. so that we can monitor when they start working again and
29+
## are reminded about those failures without making CI fail for unrelated PRs.
2530

2631
var packages*: seq[NimblePackage]
2732

28-
proc pkg(name: string; cmd = "nimble test"; url = "", useHead = true) =
29-
packages.add NimblePackage(name: name, cmd: cmd, url: url, useHead: useHead)
33+
proc pkg(name: string; cmd = "nimble test"; url = "", useHead = true, allowFailure = false) =
34+
packages.add NimblePackage(name: name, cmd: cmd, url: url, useHead: useHead, allowFailure: allowFailure)
3035

31-
# pkg "alea"
36+
pkg "alea", allowFailure = true
3237
pkg "argparse"
33-
when false:
34-
pkg "arraymancer", "nim c tests/tests_cpu.nim"
35-
# pkg "ast_pattern_matching", "nim c -r --oldgensym:on tests/test1.nim"
38+
pkg "arraymancer", "nim c tests/tests_cpu.nim", allowFailure = true
39+
pkg "ast_pattern_matching", "nim c -r --oldgensym:on tests/test1.nim", allowFailure = true
3640
pkg "awk"
3741
pkg "bigints", url = "https://github.com/Araq/nim-bigints"
3842
pkg "binaryheap", "nim c -r binaryheap.nim"
3943
pkg "BipBuffer"
40-
# pkg "blscurve" # pending https://github.com/status-im/nim-blscurve/issues/39
44+
pkg "blscurve", allowFailure = true # pending https://github.com/status-im/nim-blscurve/issues/39
4145
pkg "bncurve"
4246
pkg "brainfuck", "nim c -d:release -r tests/compile.nim"
4347
pkg "bump", "nim c --gc:arc --path:. -r tests/tbump.nim", "https://github.com/disruptek/bump"
4448
pkg "c2nim", "nim c testsuite/tester.nim"
4549
pkg "cascade"
4650
pkg "cello"
4751
pkg "chroma"
48-
# pkg "chronicles", "nim c -o:chr -r chronicles.nim"
49-
# when not defined(osx): # testdatagram.nim(560, 54): Check failed
50-
# pkg "chronos", "nim c -r -d:release tests/testall"
51-
# pending https://github.com/nim-lang/Nim/issues/17130
52-
52+
pkg "chronicles", "nim c -o:chr -r chronicles.nim", allowFailure = true # pending https://github.com/status-im/nim-chronos/issues/169
53+
pkg "chronos", "nim c -r -d:release tests/testall", allowFailure = true # pending https://github.com/nim-lang/Nim/issues/17130
5354
pkg "cligen", "nim c --path:. -r cligen.nim"
5455
pkg "combparser", "nimble test --gc:orc"
5556
pkg "compactdict"
5657
pkg "comprehension", "nimble test", "https://github.com/alehander42/comprehension"
57-
# pkg "criterion" # pending https://github.com/disruptek/criterion/issues/3 (wrongly closed)
58+
pkg "criterion", allowFailure = true # pending https://github.com/disruptek/criterion/issues/3 (wrongly closed)
5859
pkg "dashing", "nim c tests/functional.nim"
5960
pkg "delaunay"
6061
pkg "docopt"
@@ -66,12 +67,12 @@ pkg "fusion"
6667
pkg "gara"
6768
pkg "glob"
6869
pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim"
69-
# pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup"
70+
pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup", allowFailure = true
7071
pkg "gnuplot", "nim c gnuplot.nim"
7172
# pkg "gram", "nim c -r --gc:arc --define:danger tests/test.nim", "https://github.com/disruptek/gram"
7273
# pending https://github.com/nim-lang/Nim/issues/16509
7374
pkg "hts", "nim c -o:htss src/hts.nim"
74-
# pkg "httpauth"
75+
pkg "httpauth", allowFailure = true
7576
pkg "illwill", "nimble examples"
7677
pkg "inim"
7778
pkg "itertools", "nim doc src/itertools.nim"
@@ -87,28 +88,28 @@ pkg "memo"
8788
pkg "msgpack4nim", "nim c -r tests/test_spec.nim"
8889
pkg "nake", "nim c nakefile.nim"
8990
pkg "neo", "nim c -d:blas=openblas tests/all.nim"
90-
# pkg "nesm", "nimble tests" # notice plural 'tests'
91-
# pkg "nico"
91+
pkg "nesm", "nimble tests", allowFailure = true # notice plural 'tests'
92+
pkg "nico", allowFailure = true
9293
pkg "nicy", "nim c -r src/nicy.nim"
9394
pkg "nigui", "nim c -o:niguii -r src/nigui.nim"
9495
pkg "nimcrypto", "nim r --path:. tests/testall.nim" # `--path:.` workaround needed, see D20210308T165435
9596
pkg "NimData", "nim c -o:nimdataa src/nimdata.nim"
9697
pkg "nimes", "nim c src/nimes.nim"
9798
pkg "nimfp", "nim c -o:nfp -r src/fp.nim"
98-
# pkg "nimgame2", "nim c nimgame2/nimgame.nim" # XXX Doesn't work with deprecated 'randomize', will create a PR.
99+
pkg "nimgame2", "nim c nimgame2/nimgame.nim", allowFailure = true # XXX Doesn't work with deprecated 'randomize', will create a PR.
99100
pkg "nimgen", "nim c -o:nimgenn -r src/nimgen/runcfg.nim"
100101
pkg "nimlsp"
101102
pkg "nimly", "nim c -r tests/test_readme_example.nim"
102-
# pkg "nimongo", "nimble test_ci"
103-
# pkg "nimph", "nimble test", "https://github.com/disruptek/nimph"
103+
pkg "nimongo", "nimble test_ci", allowFailure = true
104+
pkg "nimph", "nimble test", "https://github.com/disruptek/nimph", allowFailure = true
104105
pkg "nimpy", "nim c -r tests/nimfrompy.nim"
105106
pkg "nimquery"
106107
pkg "nimsl"
107108
pkg "nimsvg"
108109
pkg "nimterop", "nimble minitest"
109110
pkg "nimwc", "nim c nimwc.nim"
110-
# pkg "nimx", "nim c --threads:on test/main.nim"
111-
# pkg "nitter", "nim c src/nitter.nim", "https://github.com/zedeus/nitter"
111+
pkg "nimx", "nim c --threads:on test/main.nim", allowFailure = true
112+
pkg "nitter", "nim c src/nitter.nim", "https://github.com/zedeus/nitter", allowFailure = true
112113
pkg "norm", "nim c -r tests/sqlite/trows.nim"
113114
pkg "npeg", "nimble testarc"
114115
pkg "numericalnim", "nim c -r tests/test_integrate.nim"
@@ -150,7 +151,7 @@ pkg "unicodedb", "nim c -d:release -r tests/tests.nim"
150151
pkg "unicodeplus", "nim c -d:release -r tests/tests.nim"
151152
pkg "unpack"
152153
pkg "websocket", "nim c websocket.nim"
153-
# pkg "winim"
154+
pkg "winim", allowFailure = true
154155
pkg "with"
155156
pkg "ws"
156157
pkg "yaml", "nim build"

testament/testament.nim

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ proc isNimRepoTests(): bool =
6666
type
6767
Category = distinct string
6868
TResults = object
69-
total, passed, skipped: int
69+
total, passed, failedButAllowed, skipped: int
70+
## xxx rename passed to passedOrAllowedFailure
7071
data: string
7172
TTest = object
7273
name: string
@@ -212,6 +213,7 @@ proc callCCompiler(cmdTemplate, filename, options: string,
212213
proc initResults: TResults =
213214
result.total = 0
214215
result.passed = 0
216+
result.failedButAllowed = 0
215217
result.skipped = 0
216218
result.data = ""
217219

@@ -239,16 +241,20 @@ template maybeStyledEcho(args: varargs[untyped]): untyped =
239241

240242

241243
proc `$`(x: TResults): string =
242-
result = ("Tests passed: $1 / $3 <br />\n" &
243-
"Tests skipped: $2 / $3 <br />\n") %
244-
[$x.passed, $x.skipped, $x.total]
244+
result = """
245+
Tests passed or allowed to fail: $2 / $1 <br />
246+
Tests failed and allowed to fail: $3 / $1 <br />
247+
Tests skipped: $4 / $1 <br />
248+
""" % [$x.total, $x.passed, $x.failedButAllowed, $x.skipped]
245249

246250
proc addResult(r: var TResults, test: TTest, target: TTarget,
247-
expected, given: string, successOrig: TResultEnum) =
251+
expected, given: string, successOrig: TResultEnum, allowFailure = false) =
248252
# test.name is easier to find than test.name.extractFilename
249253
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
250254
var name = test.name.replace(DirSep, '/')
251255
name.add ' ' & $target
256+
if allowFailure:
257+
name.add " (allowed to fail) "
252258
if test.options.len > 0: name.add ' ' & test.options
253259

254260
let duration = epochTime() - test.startTime

0 commit comments

Comments
 (0)