testament: fix #16829, fix partially #16830 (#16831)

* fix #16829
* address comments
This commit is contained in:
Timothee Cour 2021-01-27 08:05:48 -08:00 • committed by GitHub
commit 11a54ab2b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 65 deletions

View file

@ -54,6 +54,13 @@ On Azure Pipelines, testament will also publish test results via Azure Pipelines
provided that System.AccessToken is made available via the environment variable SYSTEM_ACCESSTOKEN.
""" % resultsFile
proc isNimRepoTests(): bool =
# this logic could either be specific to cwd, or to some file derived from
# the input file, eg testament r /pathto/tests/foo/tmain.nim; we choose
# the former since it's simpler and also works with `testament all`.
let file = "testament"/"testament.nim.cfg"
result = file.fileExists
type
Category = distinct string
TResults = object
@ -86,6 +93,11 @@ var targetsSet = false
proc isSuccess(input: string): bool =
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
# note: this doesn't handle colors, eg: `\e[1m\e[0m\e[32mHint:`; while we
# could handle colors, there would be other issues such as handling other flags
# that may appear in user config (eg: `--listFullPaths`).
# Passing `XDG_CONFIG_HOME= testament args...` can be used to ignore user config
# stored in XDG_CONFIG_HOME, refs https://wiki.archlinux.org/index.php/XDG_Base_Directory
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
proc getFileDir(filename: string): string =
@ -744,7 +756,8 @@ proc main() =
let cat = dir[testsDir.len .. ^1]
if kind == pcDir and cat notin ["testdata", "nimcache"]:
cats.add cat
cats.add AdditionalCategories
if isNimRepoTests():
cats.add AdditionalCategories
if useMegatest: cats.add MegaTestCat
var cmds: seq[string]