* refs #16576: honor matrix in testament by making such tests non joinable * add tests + misc fixes * fix test for i386 with -d:danger
This commit is contained in:
parent
6317e4004d
commit
00144ee4e9
6 changed files with 37 additions and 12 deletions
|
|
@ -49,6 +49,7 @@ proc isTestFile*(file: string): bool =
|
||||||
|
|
||||||
# ---------------- IC tests ---------------------------------------------
|
# ---------------- IC tests ---------------------------------------------
|
||||||
|
|
||||||
|
# xxx deadcode
|
||||||
proc icTests(r: var TResults; testsDir: string, cat: Category, options: string) =
|
proc icTests(r: var TResults; testsDir: string, cat: Category, options: string) =
|
||||||
const
|
const
|
||||||
tooltests = ["compiler/nim.nim", "tools/nimgrep.nim"]
|
tooltests = ["compiler/nim.nim", "tools/nimgrep.nim"]
|
||||||
|
|
@ -583,6 +584,8 @@ proc processSingleTest(r: var TResults, cat: Category, options, test: string, ta
|
||||||
testSpec r, makeTest(test, options, cat), targets
|
testSpec r, makeTest(test, options, cat), targets
|
||||||
|
|
||||||
proc isJoinableSpec(spec: TSpec): bool =
|
proc isJoinableSpec(spec: TSpec): bool =
|
||||||
|
# xxx simplify implementation using a whitelist of fields that are allowed to be
|
||||||
|
# set to non-default values (use `fieldPairs`), to avoid issues like bug #16576.
|
||||||
result = not spec.sortoutput and
|
result = not spec.sortoutput and
|
||||||
spec.action == actionRun and
|
spec.action == actionRun and
|
||||||
not fileExists(spec.file.changeFileExt("cfg")) and
|
not fileExists(spec.file.changeFileExt("cfg")) and
|
||||||
|
|
@ -595,6 +598,7 @@ proc isJoinableSpec(spec: TSpec): bool =
|
||||||
spec.exitCode == 0 and
|
spec.exitCode == 0 and
|
||||||
spec.input.len == 0 and
|
spec.input.len == 0 and
|
||||||
spec.nimout.len == 0 and
|
spec.nimout.len == 0 and
|
||||||
|
spec.matrix.len == 0 and
|
||||||
spec.outputCheck != ocSubstr and
|
spec.outputCheck != ocSubstr and
|
||||||
spec.ccodeCheck.len == 0 and
|
spec.ccodeCheck.len == 0 and
|
||||||
(spec.targets == {} or spec.targets == {targetC})
|
(spec.targets == {} or spec.targets == {targetC})
|
||||||
|
|
@ -656,7 +660,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
writeFile(megatestFile, megatest)
|
writeFile(megatestFile, megatest)
|
||||||
|
|
||||||
let root = getCurrentDir()
|
let root = getCurrentDir()
|
||||||
let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "--path:" & root, megatestFile]
|
let args = ["c", "--nimCache:" & outDir, "-d:testing", "-d:nimMegatest", "--listCmd", "--path:" & root, megatestFile]
|
||||||
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
|
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
echo "$ " & cmdLine & "\n" & buf.string
|
echo "$ " & cmdLine & "\n" & buf.string
|
||||||
|
|
@ -759,7 +763,9 @@ proc processCategory(r: var TResults, cat: Category,
|
||||||
testSpec r, test
|
testSpec r, test
|
||||||
inc testsRun
|
inc testsRun
|
||||||
if testsRun == 0:
|
if testsRun == 0:
|
||||||
const whiteListedDirs = ["deps"]
|
const whiteListedDirs = ["deps", "htmldocs", "pkgs"]
|
||||||
|
# `pkgs` because bug #16556 creates `pkgs` dirs and this can affect some users
|
||||||
|
# that try an old version of choosenim.
|
||||||
doAssert cat.string in whiteListedDirs,
|
doAssert cat.string in whiteListedDirs,
|
||||||
"Invalid category specified: '$#' not in whilelist: $#" % [cat.string, $whiteListedDirs]
|
"Invalid category specified: '$#' not in whilelist: $#" % [cat.string, $whiteListedDirs]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ type
|
||||||
disabled, enabled, leaking
|
disabled, enabled, leaking
|
||||||
|
|
||||||
TSpec* = object
|
TSpec* = object
|
||||||
|
# xxx make sure `isJoinableSpec` takes into account each field here.
|
||||||
action*: TTestAction
|
action*: TTestAction
|
||||||
file*, cmd*: string
|
file*, cmd*: string
|
||||||
input*: string
|
input*: string
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,8 @@ proc isSuccess(input: string): bool =
|
||||||
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
|
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
|
||||||
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
||||||
|
|
||||||
proc normalizeMsg(s: string): string =
|
when false: # deadcode
|
||||||
|
proc normalizeMsg(s: string): string =
|
||||||
result = newStringOfCap(s.len+1)
|
result = newStringOfCap(s.len+1)
|
||||||
for x in splitLines(s):
|
for x in splitLines(s):
|
||||||
if result.len > 0: result.add '\L'
|
if result.len > 0: result.add '\L'
|
||||||
|
|
@ -794,7 +795,7 @@ proc main() =
|
||||||
var subPath = p.key.string
|
var subPath = p.key.string
|
||||||
let nimRoot = currentSourcePath / "../.."
|
let nimRoot = currentSourcePath / "../.."
|
||||||
# makes sure points to this regardless of cwd or which nim is used to compile this.
|
# makes sure points to this regardless of cwd or which nim is used to compile this.
|
||||||
doAssert existsDir(nimRoot/testsDir) # sanity check
|
doAssert dirExists(nimRoot/testsDir) # sanity check
|
||||||
if subPath.isAbsolute: subPath = subPath.relativePath(nimRoot)
|
if subPath.isAbsolute: subPath = subPath.relativePath(nimRoot)
|
||||||
# at least one directory is required in the path, to use as a category name
|
# at least one directory is required in the path, to use as a category name
|
||||||
let pathParts = subPath.relativePath(testsDir).split({DirSep, AltSep})
|
let pathParts = subPath.relativePath(testsDir).split({DirSep, AltSep})
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
discard """
|
discard """
|
||||||
targets: "c cpp js"
|
targets: "c cpp js"
|
||||||
|
matrix:"; -d:danger"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
## xxx enable matrix:"; -d:nimTmathCase2 -d:danger --passc:-ffast-math"
|
# xxx: there should be a test with `-d:nimTmathCase2 -d:danger --passc:-ffast-math`,
|
||||||
|
# but it requires disabling certain lines with `when not defined(nimTmathCase2)`
|
||||||
|
|
||||||
import std/[math, random, os]
|
import std/[math, random, os]
|
||||||
import std/[unittest]
|
import std/[unittest]
|
||||||
|
|
@ -156,13 +158,13 @@ block:
|
||||||
doAssert(erf(6.0) > erf(5.0))
|
doAssert(erf(6.0) > erf(5.0))
|
||||||
doAssert(erfc(6.0) < erfc(5.0))
|
doAssert(erfc(6.0) < erfc(5.0))
|
||||||
|
|
||||||
|
|
||||||
# Function for approximate comparison of floats
|
|
||||||
proc `==~`(x, y: float): bool = (abs(x-y) < 1e-9)
|
proc `==~`(x, y: float): bool = (abs(x-y) < 1e-9)
|
||||||
|
# Function for approximate comparison of floats
|
||||||
|
# xxx use `almostEqual`
|
||||||
|
|
||||||
block: # prod
|
block: # prod
|
||||||
doAssert prod([1, 2, 3, 4]) == 24
|
doAssert prod([1, 2, 3, 4]) == 24
|
||||||
doAssert prod([1.5, 3.4]) == 5.1
|
doAssert prod([1.5, 3.4]).almostEqual 5.1
|
||||||
let x: seq[float] = @[]
|
let x: seq[float] = @[]
|
||||||
doAssert prod(x) == 1.0
|
doAssert prod(x) == 1.0
|
||||||
|
|
||||||
|
|
|
||||||
7
tests/testament/t16576.nim
Normal file
7
tests/testament/t16576.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
discard """
|
||||||
|
matrix:"-d:nimTest_t16576"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #16576
|
||||||
|
doAssert defined(nimTest_t16576)
|
||||||
|
doAssert not defined(nimMegatest)
|
||||||
8
tests/testament/tjoinable.nim
Normal file
8
tests/testament/tjoinable.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
discard """
|
||||||
|
output: "ok"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# checks that this is joinable
|
||||||
|
doAssert defined(testing)
|
||||||
|
doAssert defined(nimMegatest)
|
||||||
|
echo "ok" # intentional to make sure this doesn't prevent `isJoinableSpec`
|
||||||
Loading…
Add table
Add a link
Reference in a new issue