p[] instead of p^

This commit is contained in:
Araq 2011-04-11 21:42:28 +02:00
commit 3d696c3da5
12 changed files with 64 additions and 52 deletions

View file

@ -1,24 +1,5 @@
This directory contains the test cases.
Each test must have a filename of the form: ``t*.nim``
The testcases may contain the directives ``#ERROR``, ``#ERROR_IN``,
``#ERROR_MSG`` or ``#OUT``.
``#ERROR`` is used to indicate that the compiler should report
an error in the marked line (the line that contains the ``#ERROR``
directive.)
The format for ``#ERROR_IN`` is::
Each test can contain a spec in ``"""``.
#ERROR_IN filename linenumber
You can omit the extension of the filename (``.nim`` is then assumed).
The format for ``#ERROR_MSG`` is::
#ERROR_MSG message
This directive specifies the error message Nimrod shall produce.
Tests which contain none of the ``#ERROR*`` directives should compile.
Thus they are executed after successful compilation and their output
is compared to the expected results (specified with the ``#OUT``
directive). Tests which require user interaction are currently not
possible.

View file

@ -17,8 +17,11 @@ const
resultsFile = "testresults.html"
type
TTestAction = enum
actionCompile, actionRun, actionReject
TSpec {.pure.} = object
file: string
action: TTestAction
file, cmd: string
outp: string
line: int
msg: string
@ -72,13 +75,21 @@ proc parseSpec(filename: string): TSpec =
result.err = true
result.msg = ""
result.outp = ""
result.cmd = cmdTemplate
parseSpecAux:
case normalize(e.key)
of "action":
case e.value.normalize
of "compile": result.action = actionCompile
of "run": result.action = actionRun
of "reject": result.action = actionReject
else: echo ignoreMsg(p, e)
of "file": result.file = e.value
of "line": discard parseInt(e.value, result.line)
of "output": result.outp = e.value
of "errormsg", "msg": result.msg = e.value
of "disabled": result.disabled = parseCfgBool(e.value)
of "cmd": result.cmd = e.value
else: echo ignoreMsg(p, e)
# ----------------------------------------------------------------------------
@ -92,7 +103,7 @@ var
pegSuccess = peg"'Hint: operation successful'.*"
pegOfInterest = pegLineError / pegOtherError / pegSuccess
proc callCompiler(filename, options: string): TSpec =
proc callCompiler(cmdTemplate, filename, options: string): TSpec =
var c = parseCmdLine(cmdTemplate % [options, filename])
var a: seq[string] = @[] # slicing is not yet implemented :-(
for i in 1 .. c.len-1: add(a, c[i])
@ -192,7 +203,7 @@ proc reject(r: var TResults, dir, options: string) =
r.addResult(t, "", "", reIgnored)
inc(r.skipped)
else:
var given = callCompiler(test, options)
var given = callCompiler(expected.cmd, test, options)
cmpMsgs(r, expected, given, t)
proc compile(r: var TResults, pattern, options: string) =
@ -200,7 +211,7 @@ proc compile(r: var TResults, pattern, options: string) =
var t = extractFilename(test)
inc(r.total)
echo t
var given = callCompiler(test, options)
var given = callCompiler(cmdTemplate, test, options)
r.addResult(t, given.msg, if given.err: reFailure else: reSuccess)
if not given.err: inc(r.passed)
@ -214,7 +225,7 @@ proc run(r: var TResults, dir, options: string) =
r.addResult(t, "", "", reIgnored)
inc(r.skipped)
else:
var given = callCompiler(test, options)
var given = callCompiler(expected.cmd, test, options)
if given.err:
r.addResult(t, "", given.msg, reFailure)
else: