From d38dd01e85a149b79e0e002f82fc3b41b223e204 Mon Sep 17 00:00:00 2001 From: Miran Date: Mon, 6 Jul 2026 11:22:27 +0200 Subject: [PATCH] remove the `allowFailure` option from package testing (#25965) It is not used and it wastes CI resources. (cherry picked from commit ae9141200da6fb44ae2aa73827ba37593d6c738b) --- .github/workflows/ci_packages.yml | 2 +- testament/categories.nim | 16 +++++---------- testament/important_packages.nim | 9 ++------- testament/testament.nim | 33 +++++++++++++------------------ 4 files changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci_packages.yml b/.github/workflows/ci_packages.yml index fb9f474495..3ab1a10e65 100644 --- a/.github/workflows/ci_packages.yml +++ b/.github/workflows/ci_packages.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num` + batch: ["0_3", "1_3", "2_3"] # list of `index_num` include: - os: ubuntu-latest cpu: amd64 diff --git a/testament/categories.nim b/testament/categories.nim index eba1e3cb27..00c5b93dab 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -409,16 +409,13 @@ proc listPackages(packageFilter: string): seq[NimblePackage] = # at least should be a regex; a substring match makes no sense. result = pkgs.filterIt(packageFilter in it.name) else: - if testamentData0.batchArg == "allowed_failures": - result = pkgs.filterIt(it.allowFailure) - elif testamentData0.testamentNumBatch == 0: + if testamentData0.testamentNumBatch == 0: result = pkgs else: result = @[] - let pkgs2 = pkgs.filterIt(not it.allowFailure) - for i in 0.. -Tests failed and allowed to fail: $3 / $1
-Tests skipped: $4 / $1
-""" % [$x.total, $x.passed, $x.failedButAllowed, $x.skipped] +Tests passed: $2 / $1
+Tests skipped: $3 / $1
+""" % [$x.total, $x.passed, $x.skipped] -proc testName(test: TTest, target: TTarget, extraOptions: string, allowFailure: bool): string = +proc testName(test: TTest, target: TTarget, extraOptions: string): string = var name = test.name.replace(DirSep, '/') name.add ' ' & $target - if allowFailure: - name.add " (allowed to fail) " if test.options.len > 0: name.add ' ' & test.options if extraOptions.len > 0: name.add ' ' & extraOptions name.strip() proc addResult(r: var TResults, test: TTest, target: TTarget, extraOptions, expected, given: string, success: TResultEnum, duration: float, - allowFailure = false, givenSpec: ptr TSpec = nil) = + givenSpec: ptr TSpec = nil) = # instead of `ptr TSpec` we could also use `Option[TSpec]`; passing `givenSpec` makes it easier to get what we need # instead of having to pass individual fields, or abusing existing ones like expected vs given. # test.name is easier to find than test.name.extractFilename # A bit hacky but simple and works with tests/testament/tshould_not_work.nim - let name = testName(test, target, extraOptions, allowFailure) + let name = testName(test, target, extraOptions) let durationStr = duration.formatFloat(ffDecimal, precision = 2).align(5) if backendLogging: @@ -346,22 +341,22 @@ proc addResult(r: var TResults, test: TTest, target: TTarget, proc finishTest(r: var TResults, test: TTest, target: TTarget, extraOptions, expected, given: string, successOrig: TResultEnum, - allowFailure = false, givenSpec: ptr TSpec = nil) = + givenSpec: ptr TSpec = nil) = ## calculates duration of test, reports result ## `retries` option in the test is ignored let duration = epochTime() - test.startTime let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout else: successOrig - addResult(r, test, target, extraOptions, expected, given, success, duration, allowFailure, givenSpec) + addResult(r, test, target, extraOptions, expected, given, success, duration, givenSpec) proc finishTestRetryable(r: var TResults, test: TTest, target: TTarget, extraOptions, expected, given: string, successOrig: TResultEnum, - allowFailure = false, givenSpec: ptr TSpec = nil): bool = + givenSpec: ptr TSpec = nil): bool = ## if test failed and has remaining retries, return `true`, ## otherwise calculate duration and report result - ## + ## ## warning: if `true` is returned, then the result is not reported, - ## it has to be retried or `finishTest` should be called instead + ## it has to be retried or `finishTest` should be called instead result = false let duration = epochTime() - test.startTime let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout @@ -369,7 +364,7 @@ proc finishTestRetryable(r: var TResults, test: TTest, target: TTarget, if test.spec.retries > 0 and success notin {reSuccess, reDisabled, reJoined, reInvalidSpec}: return true else: - addResult(r, test, target, extraOptions, expected, given, success, duration, allowFailure, givenSpec) + addResult(r, test, target, extraOptions, expected, given, success, duration, givenSpec) proc toString(inlineError: InlineError, filename: string): string = result = "$file($line, $col) $kind: $msg" % [ @@ -497,7 +492,7 @@ proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec, return if test.spec.err != reRetry: test.startTime = epochTime() - if testName(test, target, extraOptions, false) in skips: + if testName(test, target, extraOptions) in skips: test.spec.err = reDisabled if test.spec.err in {reDisabled, reJoined}: