diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-04-20 00:02:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 09:02:35 +0200 |
commit | 68e7ed9c57605bc98d3ab7625374113386e62ee7 (patch) | |
tree | 1725ef501ffab306e5aa03aa51b45d82a1f23638 /testament | |
parent | fb02b569578e4538852cb92b350036548aa5da15 (diff) | |
download | Nim-68e7ed9c57605bc98d3ab7625374113386e62ee7.tar.gz |
important_packages: `allowed_failures` batch (#17757)
* important_packages: reserve batch 0 for allowed failures * custom batch name: allowed_failures
Diffstat (limited to 'testament')
-rw-r--r-- | testament/categories.nim | 35 | ||||
-rw-r--r-- | testament/testament.nim | 2 |
2 files changed, 26 insertions, 11 deletions
diff --git a/testament/categories.nim b/testament/categories.nim index d7848d51d..19d9e4507 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -14,6 +14,7 @@ import important_packages import std/strformat +from std/sequtils import filterIt const specialCategories = [ @@ -399,8 +400,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) = testSpec r, testObj # ----------------------------- nimble ---------------------------------------- -proc listPackages(packageFilter: string): seq[NimblePackage] = - # xxx document `packageFilter`, seems like a bad API (at least should be a regex; a substring match makes no sense) +proc listPackagesAll(): seq[NimblePackage] = var nimbleDir = getEnv("NIMBLE_DIR") if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble" let packageIndex = nimbleDir / "packages_official.json" @@ -409,14 +409,29 @@ proc listPackages(packageFilter: string): seq[NimblePackage] = for a in packageList: if a["name"].str == name: return a for pkg in important_packages.packages.items: - if isCurrentBatch(testamentData0, pkg.name) and packageFilter in pkg.name: - var pkg = pkg - if pkg.url.len == 0: - let pkg2 = findPackage(pkg.name) - if pkg2 == nil: - raise newException(ValueError, "Cannot find package '$#'." % pkg.name) - pkg.url = pkg2["url"].str - result.add pkg + var pkg = pkg + if pkg.url.len == 0: + let pkg2 = findPackage(pkg.name) + if pkg2 == nil: + raise newException(ValueError, "Cannot find package '$#'." % pkg.name) + pkg.url = pkg2["url"].str + result.add pkg + +proc listPackages(packageFilter: string): seq[NimblePackage] = + let pkgs = listPackagesAll() + if packageFilter.len != 0: + # xxx document `packageFilter`, seems like a bad API, + # at least should be a regex; a substring match makes no sense. + result = pkgs.filterIt(packageFilter in it.name) + else: + let pkgs1 = pkgs.filterIt(it.allowFailure) + let pkgs2 = pkgs.filterIt(not it.allowFailure) + if testamentData0.batchArg == "allowed_failures": + result = pkgs1 + else: + for i in 0..<pkgs2.len: + if i mod testamentData0.testamentNumBatch == testamentData0.testamentBatch: + result.add pkgs2[i] proc makeSupTest(test, options: string, cat: Category, debugInfo = ""): TTest = result.cat = cat diff --git a/testament/testament.nim b/testament/testament.nim index b9e8f3b95..f2a8e9055 100644 --- a/testament/testament.nim +++ b/testament/testament.nim @@ -692,7 +692,7 @@ proc main() = quit Usage of "batch": testamentData0.batchArg = p.val - if p.val != "_": + if p.val != "_" and p.val.len > 0 and p.val[0] in {'0'..'9'}: let s = p.val.split("_") doAssert s.len == 2, $(p.val, s) testamentData0.testamentBatch = s[0].parseInt |