Skip to content

Commit 094d86f

Browse files
authored
testament: use full test name in skips [backport] (nim-lang#19937)
testament: use full test name in skips
1 parent cf78c02 commit 094d86f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

testament/testament.nim

+13-7
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,23 @@ Tests failed and allowed to fail: $3 / $1 <br />
258258
Tests skipped: $4 / $1 <br />
259259
""" % [$x.total, $x.passed, $x.failedButAllowed, $x.skipped]
260260

261-
proc addResult(r: var TResults, test: TTest, target: TTarget,
262-
extraOptions, expected, given: string, successOrig: TResultEnum,
263-
allowFailure = false, givenSpec: ptr TSpec = nil) =
264-
# instead of `ptr TSpec` we could also use `Option[TSpec]`; passing `givenSpec` makes it easier to get what we need
265-
# instead of having to pass individual fields, or abusing existing ones like expected vs given.
266-
# test.name is easier to find than test.name.extractFilename
267-
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
261+
proc testName(test: TTest, target: TTarget, extraOptions: string, allowFailure: bool): string =
268262
var name = test.name.replace(DirSep, '/')
269263
name.add ' ' & $target
270264
if allowFailure:
271265
name.add " (allowed to fail) "
272266
if test.options.len > 0: name.add ' ' & test.options
273267
if extraOptions.len > 0: name.add ' ' & extraOptions
268+
name.strip()
274269

270+
proc addResult(r: var TResults, test: TTest, target: TTarget,
271+
extraOptions, expected, given: string, successOrig: TResultEnum,
272+
allowFailure = false, givenSpec: ptr TSpec = nil) =
273+
# instead of `ptr TSpec` we could also use `Option[TSpec]`; passing `givenSpec` makes it easier to get what we need
274+
# instead of having to pass individual fields, or abusing existing ones like expected vs given.
275+
# test.name is easier to find than test.name.extractFilename
276+
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
277+
let name = testName(test, target, extraOptions, allowFailure)
275278
let duration = epochTime() - test.startTime
276279
let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout
277280
else: successOrig
@@ -470,6 +473,9 @@ proc equalModuloLastNewline(a, b: string): bool =
470473
proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec,
471474
target: TTarget, extraOptions: string, nimcache: string) =
472475
test.startTime = epochTime()
476+
if testName(test, target, extraOptions, false) in skips:
477+
test.spec.err = reDisabled
478+
473479
if test.spec.err in {reDisabled, reJoined}:
474480
r.addResult(test, target, extraOptions, "", "", test.spec.err)
475481
inc(r.skipped)

0 commit comments

Comments
 (0)