test can fail because of invalid spec
This commit is contained in:
parent
a22bf14bb6
commit
199018ef2e
3 changed files with 34 additions and 19 deletions
|
|
@ -386,17 +386,6 @@ proc warningStr*(c: CfgParser, msg: string): string {.rtl, extern: "npc$1".} =
|
||||||
result = `%`("$1($2, $3) Warning: $4",
|
result = `%`("$1($2, $3) Warning: $4",
|
||||||
[c.filename, $getLine(c), $getColumn(c), msg])
|
[c.filename, $getLine(c), $getColumn(c), msg])
|
||||||
|
|
||||||
proc ignoreMsg*(c: CfgParser, e: CfgEvent): string {.rtl, extern: "npc$1".} =
|
|
||||||
## returns a properly formatted warning message containing that
|
|
||||||
## an entry is ignored.
|
|
||||||
case e.kind
|
|
||||||
of cfgSectionStart: result = c.warningStr("section ignored: " & e.section)
|
|
||||||
of cfgKeyValuePair: result = c.warningStr("key ignored: " & e.key)
|
|
||||||
of cfgOption:
|
|
||||||
result = c.warningStr("command ignored: " & e.key & ": " & e.value)
|
|
||||||
of cfgError: result = e.msg
|
|
||||||
of cfgEof: result = ""
|
|
||||||
|
|
||||||
proc getKeyValPair(c: var CfgParser, kind: CfgEventKind): CfgEvent =
|
proc getKeyValPair(c: var CfgParser, kind: CfgEventKind): CfgEvent =
|
||||||
if c.tok.kind == tkSymbol:
|
if c.tok.kind == tkSymbol:
|
||||||
result.kind = kind
|
result.kind = kind
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ type
|
||||||
reBuildFailed # package building failed
|
reBuildFailed # package building failed
|
||||||
reIgnored, # test is ignored
|
reIgnored, # test is ignored
|
||||||
reSuccess # test was successful
|
reSuccess # test was successful
|
||||||
|
reInvalidSpec # test had problems to parse the spec
|
||||||
|
|
||||||
TTarget* = enum
|
TTarget* = enum
|
||||||
targetC = "C"
|
targetC = "C"
|
||||||
|
|
@ -68,6 +69,7 @@ type
|
||||||
err*: TResultEnum
|
err*: TResultEnum
|
||||||
targets*: set[TTarget]
|
targets*: set[TTarget]
|
||||||
nimout*: string
|
nimout*: string
|
||||||
|
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
||||||
|
|
||||||
const
|
const
|
||||||
targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
|
targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
|
||||||
|
|
@ -108,6 +110,16 @@ proc parseTargets*(value: string): set[TTarget] =
|
||||||
of "js": result.incl(targetJS)
|
of "js": result.incl(targetJS)
|
||||||
else: echo "target ignored: " & v
|
else: echo "target ignored: " & v
|
||||||
|
|
||||||
|
|
||||||
|
proc addLine(self: var string; a: string) =
|
||||||
|
self.add a
|
||||||
|
self.add "\n"
|
||||||
|
|
||||||
|
proc addLine(self: var string; a,b: string) =
|
||||||
|
self.add a
|
||||||
|
self.add b
|
||||||
|
self.add "\n"
|
||||||
|
|
||||||
proc parseSpec*(filename: string): TSpec =
|
proc parseSpec*(filename: string): TSpec =
|
||||||
result = defaultSpec()
|
result = defaultSpec()
|
||||||
result.file = filename
|
result.file = filename
|
||||||
|
|
@ -129,7 +141,7 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
of "reject":
|
of "reject":
|
||||||
result.action = actionReject
|
result.action = actionReject
|
||||||
else:
|
else:
|
||||||
echo ignoreMsg(p, e)
|
result.parseErrors.addLine "cannot interpret as action: ", e.value
|
||||||
of "file":
|
of "file":
|
||||||
result.file = e.value
|
result.file = e.value
|
||||||
of "line":
|
of "line":
|
||||||
|
|
@ -151,7 +163,10 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.outputCheck = ocSubstr
|
result.outputCheck = ocSubstr
|
||||||
result.outp = strip(e.value)
|
result.outp = strip(e.value)
|
||||||
of "sortoutput":
|
of "sortoutput":
|
||||||
result.sortoutput = parseCfgBool(e.value)
|
try:
|
||||||
|
result.sortoutput = parseCfgBool(e.value)
|
||||||
|
except:
|
||||||
|
result.parseErrors.addLine getCurrentExceptionMsg()
|
||||||
of "exitcode":
|
of "exitcode":
|
||||||
discard parseInt(e.value, result.exitCode)
|
discard parseInt(e.value, result.exitCode)
|
||||||
result.action = actionRun
|
result.action = actionRun
|
||||||
|
|
@ -185,7 +200,7 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
of "appveyor":
|
of "appveyor":
|
||||||
if isAppVeyor: result.err = reIgnored
|
if isAppVeyor: result.err = reIgnored
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError, "cannot interpret as a bool: " & e.value)
|
result.parseErrors.addLine "cannot interpret as a bool: ", e.value
|
||||||
of "cmd":
|
of "cmd":
|
||||||
if e.value.startsWith("nim "):
|
if e.value.startsWith("nim "):
|
||||||
result.cmd = compilerPrefix & e.value[3..^1]
|
result.cmd = compilerPrefix & e.value[3..^1]
|
||||||
|
|
@ -207,12 +222,18 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
of "js":
|
of "js":
|
||||||
result.targets.incl(targetJS)
|
result.targets.incl(targetJS)
|
||||||
else:
|
else:
|
||||||
echo ignoreMsg(p, e)
|
result.parseErrors.addLine "cannot interpret as a target: ", e.value
|
||||||
else:
|
else:
|
||||||
echo ignoreMsg(p, e)
|
result.parseErrors.addLine "invalid key for test spec: ", e.key
|
||||||
|
|
||||||
of cfgSectionStart, cfgOption, cfgError:
|
of cfgSectionStart:
|
||||||
echo ignoreMsg(p, e)
|
result.parseErrors.addLine "section ignored: ", e.section
|
||||||
|
of cfgOption:
|
||||||
|
result.parseErrors.addLine "command ignored: ", e.key & ": " & e.value
|
||||||
|
of cfgError:
|
||||||
|
result.parseErrors.addLine e.msg
|
||||||
of cfgEof:
|
of cfgEof:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
close(p)
|
close(p)
|
||||||
|
|
|
||||||
|
|
@ -347,9 +347,14 @@ proc compilerOutputTests(test: TTest, target: TTarget, given: var TSpec,
|
||||||
|
|
||||||
proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
var expected = test.spec
|
var expected = test.spec
|
||||||
|
if expected.parseErrors.len > 0:
|
||||||
|
# targetC is a lie, but parameter is required
|
||||||
|
r.addResult(test, targetC, "", expected.parseErrors, reInvalidSpec)
|
||||||
|
inc(r.total)
|
||||||
|
return
|
||||||
|
|
||||||
if expected.err == reIgnored:
|
if expected.err == reIgnored:
|
||||||
# targetC is a lie
|
# targetC is a lie, but parameter is required
|
||||||
r.addResult(test, targetC, "", "", reIgnored)
|
r.addResult(test, targetC, "", "", reIgnored)
|
||||||
inc(r.skipped)
|
inc(r.skipped)
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue