Tester now appreciates the test target. Modified 'cmd' in specs.

This commit is contained in:
Dominik Picheta
2014-04-16 21:28:19 +01:00
parent 6692d95ee2
commit 2fb5d62927
24 changed files with 31 additions and 31 deletions

View File

@@ -1,6 +1,5 @@
discard """
file: "tasyncawait.nim"
cmd: "nimrod cc --hints:on $# $#"
output: "5000"
"""
import asyncdispatch, rawsockets, net, strutils, os

View File

@@ -1,6 +1,6 @@
discard """
file: "tasynciossl.nim"
cmd: "nimrod cc --hints:on --define:ssl $# $#"
cmd: "nimrod $target --hints:on --define:ssl $options $file"
output: "20000"
"""
import sockets, asyncio, strutils, times
@@ -88,4 +88,4 @@ while true:
break
assert msgCount == (swarmSize * messagesToSend) * serverCount
echo(msgCount)
echo(msgCount)

View File

@@ -1,6 +1,6 @@
discard """
outputsub: "101"
cmd: "nimrod cc --hints:on --threads:on $# $#"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""
import os, locks

View File

@@ -1,6 +1,6 @@
discard """
output: "Done"
cmd: "nimrod cc --debuginfo --hints:on --define:useNimRtl $# $#"
cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl $options $file"
"""
type

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod cc --debuginfo --hints:on --define:useNimRtl --app:lib $# $#"
cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl --app:lib $options $file"
"""
type

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod check $# $#"
cmd: "nimrod check $options $file"
errormsg: "'proc' is not a concrete type"
errormsg: "'Foo' is not a concrete type."
errormsg: "invalid type: 'TBaseMed'"

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod cc --hints:on --threads:on $# $#"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""
type

View File

@@ -1,6 +1,6 @@
discard """
output: '''true'''
cmd: "nimrod cc --gc:none --hints:on --warnings:off $# $#"
cmd: "nimrod $target --gc:none --hints:on --warnings:off $options $file"
"""
import hashes

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod js --hints:on $# $#"
cmd: "nimrod js --hints:on $options $file"
"""
# This file tests the JavaScript generator

View File

@@ -1,5 +1,4 @@
discard """
cmd: "nimrod js --hints:on $# $#"
output: "1261129"
"""

View File

@@ -1,5 +1,4 @@
discard """
cmd: "nimrod js --hints:on -r $# $#"
output: '''foo
js 3.14'''
"""

View File

@@ -1,5 +1,4 @@
discard """
cmd: "nimrod js --hints:on -r $# $#"
output: '''true'''
"""

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod cc --hints:on -d:release $# $#"
cmd: "nimrod $target --hints:on -d:release $options $file"
"""
# -*- nimrod -*-

View File

@@ -1,6 +1,5 @@
discard """
output: '''true'''
cmd: "nimrod cc --hints:on $# $#"
"""
import hashes, sets

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod cc --hints:on -d:embedUnidecodeTable $# $#"
cmd: "nimrod $target --hints:on -d:embedUnidecodeTable $options $file"
output: "Ausserst"
"""

View File

@@ -1,6 +1,5 @@
discard """
output: '''true'''
cmd: "nimrod cc --hints:on $# $#"
"""
import hashes, tables

View File

@@ -1,6 +1,5 @@
discard """
output: '''true'''
cmd: "nimrod cc --hints:on $# $#"
"""
import tables

View File

@@ -10,7 +10,7 @@
import parseutils, strutils, os, osproc, streams, parsecfg
const
cmdTemplate* = r"nimrod cc --hints:on $# $#"
cmdTemplate* = r"nimrod $target --hints:on $options $file"
type
TTestAction* = enum
@@ -51,6 +51,7 @@ type
const
targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
targetToCmd*: array[TTarget, string] = ["c", "cpp", "objc", "js"]
when not defined(parseCfgBool):
# candidate for the stdlib:

View File

@@ -53,8 +53,10 @@ let
pegSuccess = peg"'Hint: operation successful'.*"
pegOfInterest = pegLineError / pegOtherError
proc callCompiler(cmdTemplate, filename, options: string): TSpec =
let c = parseCmdLine(cmdTemplate % [options, filename])
proc callCompiler(cmdTemplate, filename, options: string,
target: TTarget): TSpec =
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
"options", options, "file", filename])
var p = startProcess(command=c[0], args=c[1.. -1],
options={poStdErrToStdOut, poUseShell})
let outp = p.outputStream
@@ -160,13 +162,15 @@ proc testSpec(r: var TResults, test: TTest) =
else:
case expected.action
of actionCompile:
var given = callCompiler(expected.cmd, test.name, test.options)
var given = callCompiler(expected.cmd, test.name, test.options,
test.target)
if given.err == reSuccess:
codegenCheck(test, expected.ccodeCheck, given)
r.addResult(test, "", given.msg, given.err)
if given.err == reSuccess: inc(r.passed)
of actionRun:
var given = callCompiler(expected.cmd, test.name, test.options)
var given = callCompiler(expected.cmd, test.name, test.options,
test.target)
if given.err != reSuccess:
r.addResult(test, "", given.msg, given.err)
else:
@@ -178,7 +182,8 @@ proc testSpec(r: var TResults, test: TTest) =
exeFile = changeFileExt(tname, ExeExt)
if existsFile(exeFile):
if test.target == targetJS and findExe("nodejs") == "":
r.addResult(test, expected.outp, "nodejs binary not in PATH", reExeNotFound)
r.addResult(test, expected.outp, "nodejs binary not in PATH",
reExeNotFound)
return
var (buf, exitCode) = execCmdEx(
(if test.target == targetJS: "nodejs " else: "") & exeFile)
@@ -196,7 +201,8 @@ proc testSpec(r: var TResults, test: TTest) =
else:
r.addResult(test, expected.outp, "executable not found", reExeNotFound)
of actionReject:
var given = callCompiler(expected.cmd, test.name, test.options)
var given = callCompiler(expected.cmd, test.name, test.options,
test.target)
cmpMsgs(r, expected, given, test)
proc testNoSpec(r: var TResults, test: TTest) =
@@ -204,7 +210,7 @@ proc testNoSpec(r: var TResults, test: TTest) =
let tname = test.name.addFileExt(".nim")
inc(r.total)
echo extractFilename(tname)
let given = callCompiler(cmdTemplate, test.name, test.options)
let given = callCompiler(cmdTemplate, test.name, test.options, test.target)
r.addResult(test, "", given.msg, given.err)
if given.err == reSuccess: inc(r.passed)

View File

@@ -2,7 +2,7 @@ discard """
outputsub: "101"
msg: "Warning: write to foreign heap"
line: 37
cmd: "nimrod cc --hints:on --threads:on $# $#"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""
import os

View File

@@ -2,7 +2,7 @@ discard """
file: "tthreadanalysis2.nim"
line: 42
errormsg: "write to foreign heap"
cmd: "nimrod cc --hints:on --threads:on $# $#"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""
import os

View File

@@ -2,7 +2,7 @@ discard """
file: "tthreadanalysis3.nim"
line: 35
errormsg: "write to foreign heap"
cmd: "nimrod cc --hints:on --threads:on $# $#"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""
import os

View File

@@ -1,7 +1,7 @@
discard """
line: 12
errormsg: "write to foreign heap"
cmd: "nimrod cc --hints:on --threads:on $# $#"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""
var

View File

@@ -1,5 +1,5 @@
discard """
cmd: "nimrod c --threads:on $# $#"
cmd: "nimrod $target --threads:on $options $file"
errormsg: "illegal recursion in type 'TIRC'"
line: 16
"""