compiler option for testament (#5713)

* compiler option for testament

* different spacing
This commit is contained in:
Jacek Sieka
2017-05-15 22:34:30 +08:00
committed by Andreas Rumpf
parent 3afd852f54
commit 6bbf0fb64d
2 changed files with 11 additions and 6 deletions

View File

@@ -9,8 +9,11 @@
import parseutils, strutils, os, osproc, streams, parsecfg
const
cmdTemplate* = r"compiler" / "nim $target --lib:lib --hints:on -d:testing $options $file"
var compilerPrefix* = "compiler" / "nim "
proc cmdTemplate*(): string =
compilerPrefix & "$target --lib:lib --hints:on -d:testing $options $file"
type
TTestAction* = enum
@@ -100,7 +103,7 @@ proc specDefaults*(result: var TSpec) =
result.outp = ""
result.nimout = ""
result.ccodeCheck = ""
result.cmd = cmdTemplate
result.cmd = cmdTemplate()
result.line = 0
result.column = 0
result.tfile = ""
@@ -173,7 +176,7 @@ proc parseSpec*(filename: string): TSpec =
raise newException(ValueError, "cannot interpret as a bool: " & e.value)
of "cmd":
if e.value.startsWith("nim "):
result.cmd = "compiler" / e.value
result.cmd = compilerPrefix & e.value[4..^1]
else:
result.cmd = e.value
of "ccodecheck": result.ccodeCheck = e.value

View File

@@ -34,6 +34,7 @@ Options:
--failing only show failing/ignored tests
--pedantic return non-zero status code if there are failures
--targets:"c c++ js objc" run tests for specified targets (default: all)
--nim:path use a particular nim executable (default: compiler/nim)
""" % resultsFile
type
@@ -367,7 +368,7 @@ proc testNoSpec(r: var TResults, test: TTest) =
# does not extract the spec because the file is not supposed to have any
#let tname = test.name.addFileExt(".nim")
inc(r.total)
let given = callCompiler(cmdTemplate, test.name, test.options, test.target)
let given = callCompiler(cmdTemplate(), test.name, test.options, test.target)
r.addResult(test, "", given.msg, given.err)
if given.err == reSuccess: inc(r.passed)
@@ -376,7 +377,7 @@ proc testC(r: var TResults, test: TTest) =
let tname = test.name.addFileExt(".c")
inc(r.total)
styledEcho "Processing ", fgCyan, extractFilename(tname)
var given = callCCompiler(cmdTemplate, test.name & ".c", test.options, test.target)
var given = callCCompiler(cmdTemplate(), test.name & ".c", test.options, test.target)
if given.err != reSuccess:
r.addResult(test, "", given.msg, given.err)
elif test.action == actionRun:
@@ -424,6 +425,7 @@ proc main() =
of "failing": optFailing = true
of "pedantic": optPedantic = true
of "targets": targets = parseTargets(p.val.string)
of "nim": compilerPrefix = p.val.string
else: quit Usage
p.next()
if p.kind != cmdArgument: quit Usage