important_packages: allowed_failures batch (#17757)

* important_packages: reserve batch 0 for allowed failures

* custom batch name: allowed_failures
This commit is contained in:
Timothee Cour 2021-04-20 00:02:35 -07:00 • committed by GitHub
commit 68e7ed9c57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 12 deletions

View file

@ -11,7 +11,7 @@ jobs:
matrix: matrix:
os: [ubuntu-18.04, macos-10.15] os: [ubuntu-18.04, macos-10.15]
cpu: [amd64] cpu: [amd64]
batch: ["0_3", "1_3", "2_3"] # list of `index_num` batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num`
name: '${{ matrix.os }} (batch: ${{ matrix.batch }})' name: '${{ matrix.os }} (batch: ${{ matrix.batch }})'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:

View file

@ -14,6 +14,7 @@
import important_packages import important_packages
import std/strformat import std/strformat
from std/sequtils import filterIt
const const
specialCategories = [ specialCategories = [
@ -399,8 +400,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
testSpec r, testObj testSpec r, testObj
# ----------------------------- nimble ---------------------------------------- # ----------------------------- nimble ----------------------------------------
proc listPackages(packageFilter: string): seq[NimblePackage] = proc listPackagesAll(): seq[NimblePackage] =
# xxx document `packageFilter`, seems like a bad API (at least should be a regex; a substring match makes no sense)
var nimbleDir = getEnv("NIMBLE_DIR") var nimbleDir = getEnv("NIMBLE_DIR")
if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble" if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble"
let packageIndex = nimbleDir / "packages_official.json" let packageIndex = nimbleDir / "packages_official.json"
@ -409,14 +409,29 @@ proc listPackages(packageFilter: string): seq[NimblePackage] =
for a in packageList: for a in packageList:
if a["name"].str == name: return a if a["name"].str == name: return a
for pkg in important_packages.packages.items: for pkg in important_packages.packages.items:
if isCurrentBatch(testamentData0, pkg.name) and packageFilter in pkg.name: var pkg = pkg
var pkg = pkg if pkg.url.len == 0:
if pkg.url.len == 0: let pkg2 = findPackage(pkg.name)
let pkg2 = findPackage(pkg.name) if pkg2 == nil:
if pkg2 == nil: raise newException(ValueError, "Cannot find package '$#'." % pkg.name)
raise newException(ValueError, "Cannot find package '$#'." % pkg.name) pkg.url = pkg2["url"].str
pkg.url = pkg2["url"].str result.add pkg
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 = proc makeSupTest(test, options: string, cat: Category, debugInfo = ""): TTest =
result.cat = cat result.cat = cat

View file

@ -692,7 +692,7 @@ proc main() =
quit Usage quit Usage
of "batch": of "batch":
testamentData0.batchArg = p.val 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("_") let s = p.val.split("_")
doAssert s.len == 2, $(p.val, s) doAssert s.len == 2, $(p.val, s)
testamentData0.testamentBatch = s[0].parseInt testamentData0.testamentBatch = s[0].parseInt