[bugfix] Make std/unittest compile with --styleCheck:error (#11762)
This commit is contained in:
parent
210988c532
commit
404b224945
1 changed files with 8 additions and 8 deletions
|
|
@ -190,7 +190,7 @@ proc defaultConsoleFormatter*(): <//>ConsoleOutputFormatter =
|
||||||
var envOutLvl = os.getEnv("NIMTEST_OUTPUT_LVL").string
|
var envOutLvl = os.getEnv("NIMTEST_OUTPUT_LVL").string
|
||||||
var colorOutput = isatty(stdout)
|
var colorOutput = isatty(stdout)
|
||||||
if existsEnv("NIMTEST_COLOR"):
|
if existsEnv("NIMTEST_COLOR"):
|
||||||
let colorEnv = getenv("NIMTEST_COLOR")
|
let colorEnv = getEnv("NIMTEST_COLOR")
|
||||||
if colorEnv == "never":
|
if colorEnv == "never":
|
||||||
colorOutput = false
|
colorOutput = false
|
||||||
elif colorEnv == "always":
|
elif colorEnv == "always":
|
||||||
|
|
@ -349,7 +349,7 @@ proc glob(matcher, filter: string): bool =
|
||||||
let beforeAndAfter = filter.split('*', maxsplit=1)
|
let beforeAndAfter = filter.split('*', maxsplit=1)
|
||||||
if beforeAndAfter.len == 1:
|
if beforeAndAfter.len == 1:
|
||||||
# "foo*"
|
# "foo*"
|
||||||
return matcher.startswith(beforeAndAfter[0])
|
return matcher.startsWith(beforeAndAfter[0])
|
||||||
|
|
||||||
if matcher.len < filter.len - 1:
|
if matcher.len < filter.len - 1:
|
||||||
return false # "12345" should not match "123*345"
|
return false # "12345" should not match "123*345"
|
||||||
|
|
@ -366,8 +366,8 @@ proc matchFilter(suiteName, testName, filter: string): bool =
|
||||||
|
|
||||||
if suiteAndTestFilters.len == 1:
|
if suiteAndTestFilters.len == 1:
|
||||||
# no suite specified
|
# no suite specified
|
||||||
let test_f = suiteAndTestFilters[0]
|
let testFilter = suiteAndTestFilters[0]
|
||||||
return glob(testName, test_f)
|
return glob(testName, testFilter)
|
||||||
|
|
||||||
return glob(suiteName, suiteAndTestFilters[0]) and glob(testName, suiteAndTestFilters[1])
|
return glob(suiteName, suiteAndTestFilters[0]) and glob(testName, suiteAndTestFilters[1])
|
||||||
|
|
||||||
|
|
@ -627,7 +627,7 @@ macro check*(conditions: untyped): untyped =
|
||||||
# Ident !"v"
|
# Ident !"v"
|
||||||
# IntLit 2
|
# IntLit 2
|
||||||
result.check[i] = exp[i][1]
|
result.check[i] = exp[i][1]
|
||||||
if exp[i].typekind notin {ntyTypeDesc}:
|
if exp[i].typeKind notin {ntyTypeDesc}:
|
||||||
let arg = newIdentNode(":p" & $counter)
|
let arg = newIdentNode(":p" & $counter)
|
||||||
result.assigns.add getAst(asgn(arg, paramAst))
|
result.assigns.add getAst(asgn(arg, paramAst))
|
||||||
result.printOuts.add getAst(print(argStr, arg))
|
result.printOuts.add getAst(print(argStr, arg))
|
||||||
|
|
@ -640,7 +640,7 @@ macro check*(conditions: untyped): untyped =
|
||||||
of nnkCallKinds:
|
of nnkCallKinds:
|
||||||
|
|
||||||
let (assigns, check, printOuts) = inspectArgs(checked)
|
let (assigns, check, printOuts) = inspectArgs(checked)
|
||||||
let lineinfo = newStrLitNode(checked.lineinfo)
|
let lineinfo = newStrLitNode(checked.lineInfo)
|
||||||
let callLit = checked.toStrLit
|
let callLit = checked.toStrLit
|
||||||
result = quote do:
|
result = quote do:
|
||||||
block:
|
block:
|
||||||
|
|
@ -657,7 +657,7 @@ macro check*(conditions: untyped): untyped =
|
||||||
result.add(newCall(!"check", node))
|
result.add(newCall(!"check", node))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
let lineinfo = newStrLitNode(checked.lineinfo)
|
let lineinfo = newStrLitNode(checked.lineInfo)
|
||||||
let callLit = checked.toStrLit
|
let callLit = checked.toStrLit
|
||||||
|
|
||||||
result = quote do:
|
result = quote do:
|
||||||
|
|
@ -712,7 +712,7 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped =
|
||||||
for i in countup(1, exp.len - 2):
|
for i in countup(1, exp.len - 2):
|
||||||
errorTypes.add(exp[i])
|
errorTypes.add(exp[i])
|
||||||
|
|
||||||
result = getAst(expectBody(errorTypes, exp.lineinfo, body))
|
result = getAst(expectBody(errorTypes, exp.lineInfo, body))
|
||||||
|
|
||||||
proc disableParamFiltering* =
|
proc disableParamFiltering* =
|
||||||
## disables filtering tests with the command line params
|
## disables filtering tests with the command line params
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue