Merge pull request #2575 from nanoant/test-for-error-location-column
Tests: Optional error location column spec
This commit is contained in:
commit
3e2c086b1f
2 changed files with 15 additions and 6 deletions
|
|
@ -42,7 +42,8 @@ type
|
||||||
action*: TTestAction
|
action*: TTestAction
|
||||||
file*, cmd*: string
|
file*, cmd*: string
|
||||||
outp*: string
|
outp*: string
|
||||||
line*, exitCode*: int
|
line*, column*: int
|
||||||
|
exitCode*: int
|
||||||
msg*: string
|
msg*: string
|
||||||
ccodeCheck*: string
|
ccodeCheck*: string
|
||||||
err*: TResultEnum
|
err*: TResultEnum
|
||||||
|
|
@ -98,6 +99,8 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.nimout = ""
|
result.nimout = ""
|
||||||
result.ccodeCheck = ""
|
result.ccodeCheck = ""
|
||||||
result.cmd = cmdTemplate
|
result.cmd = cmdTemplate
|
||||||
|
result.line = 0
|
||||||
|
result.column = 0
|
||||||
parseSpecAux:
|
parseSpecAux:
|
||||||
case normalize(e.key)
|
case normalize(e.key)
|
||||||
of "action":
|
of "action":
|
||||||
|
|
@ -108,6 +111,7 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
else: echo ignoreMsg(p, e)
|
else: echo ignoreMsg(p, e)
|
||||||
of "file": result.file = e.value
|
of "file": result.file = e.value
|
||||||
of "line": discard parseInt(e.value, result.line)
|
of "line": discard parseInt(e.value, result.line)
|
||||||
|
of "column": discard parseInt(e.value, result.column)
|
||||||
of "output":
|
of "output":
|
||||||
result.action = actionRun
|
result.action = actionRun
|
||||||
result.outp = e.value
|
result.outp = e.value
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ type
|
||||||
|
|
||||||
let
|
let
|
||||||
pegLineError =
|
pegLineError =
|
||||||
peg"{[^(]*} '(' {\d+} ', ' \d+ ') ' ('Error') ':' \s* {.*}"
|
peg"{[^(]*} '(' {\d+} ', ' {\d+} ') ' ('Error') ':' \s* {.*}"
|
||||||
pegOtherError = peg"'Error:' \s* {.*}"
|
pegOtherError = peg"'Error:' \s* {.*}"
|
||||||
pegSuccess = peg"'Hint: operation successful'.*"
|
pegSuccess = peg"'Hint: operation successful'.*"
|
||||||
pegOfInterest = pegLineError / pegOtherError
|
pegOfInterest = pegLineError / pegOtherError
|
||||||
|
|
@ -77,11 +77,13 @@ proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
result.msg = ""
|
result.msg = ""
|
||||||
result.file = ""
|
result.file = ""
|
||||||
result.outp = ""
|
result.outp = ""
|
||||||
result.line = -1
|
result.line = 0
|
||||||
|
result.column = 0
|
||||||
if err =~ pegLineError:
|
if err =~ pegLineError:
|
||||||
result.file = extractFilename(matches[0])
|
result.file = extractFilename(matches[0])
|
||||||
result.line = parseInt(matches[1])
|
result.line = parseInt(matches[1])
|
||||||
result.msg = matches[2]
|
result.column = parseInt(matches[2])
|
||||||
|
result.msg = matches[3]
|
||||||
elif err =~ pegOtherError:
|
elif err =~ pegOtherError:
|
||||||
result.msg = matches[0]
|
result.msg = matches[0]
|
||||||
elif suc =~ pegSuccess:
|
elif suc =~ pegSuccess:
|
||||||
|
|
@ -130,8 +132,11 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
|
||||||
elif extractFilename(expected.file) != extractFilename(given.file) and
|
elif extractFilename(expected.file) != extractFilename(given.file) and
|
||||||
"internal error:" notin expected.msg:
|
"internal error:" notin expected.msg:
|
||||||
r.addResult(test, expected.file, given.file, reFilesDiffer)
|
r.addResult(test, expected.file, given.file, reFilesDiffer)
|
||||||
elif expected.line != given.line and expected.line != 0:
|
elif expected.line != given.line and expected.line != 0 or
|
||||||
r.addResult(test, $expected.line, $given.line, reLinesDiffer)
|
expected.column != given.column and expected.column != 0:
|
||||||
|
r.addResult(test, $expected.line & ':' & $expected.column,
|
||||||
|
$given.line & ':' & $given.column,
|
||||||
|
reLinesDiffer)
|
||||||
else:
|
else:
|
||||||
r.addResult(test, expected.msg, given.msg, reSuccess)
|
r.addResult(test, expected.msg, given.msg, reSuccess)
|
||||||
inc(r.passed)
|
inc(r.passed)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue