add nim c -r nimsuggest/tester to travis (#8805)

This commit is contained in:
Timothee Cour 2018-08-29 07:03:16 -07:00 • committed by Andreas Rumpf
commit 01211ced1d
10 changed files with 27 additions and 3 deletions

View file

@ -7,9 +7,10 @@ import os, osproc, strutils, streams, re, sexp, net
type
Test = object
cmd, dest: string
filename, cmd, dest: string
startup: seq[string]
script: seq[(string, string)]
disabled: bool
const
curDir = when defined(windows): "" else: ""
@ -21,6 +22,7 @@ proc parseTest(filename: string; epcMode=false): Test =
const cursorMarker = "#[!]#"
let nimsug = curDir & addFileExt("nimsuggest", ExeExt)
let libpath = findExe("nim").splitFile().dir /../ "lib"
result.filename = filename
result.dest = getTempDir() / extractFilename(filename)
result.cmd = nimsug & " --tester " & result.dest
result.script = @[]
@ -42,7 +44,14 @@ proc parseTest(filename: string; epcMode=false): Test =
if x.contains("""""""""):
inc specSection
elif specSection == 1:
if x.startsWith("$nimsuggest"):
if x.startsWith("disabled:"):
if x.startsWith("disabled:true"):
result.disabled = true
else:
# be strict about format
doAssert x.startsWith("disabled:false")
result.disabled = false
elif x.startsWith("$nimsuggest"):
result.cmd = x % ["nimsuggest", nimsug, "file", filename, "lib", libpath]
elif x.startsWith("!"):
if result.cmd.len == 0:
@ -223,8 +232,14 @@ proc doReport(filename, answer, resp: string; report: var string) =
report.add "\n Expected: " & resp
report.add "\n But got: " & answer
proc skipDisabledTest(test: Test): bool =
if test.disabled:
echo "disabled: " & test.filename
result = test.disabled
proc runEpcTest(filename: string): int =
let s = parseTest(filename, true)
if s.skipDisabledTest: return 0
for cmd in s.startup:
if not runCmd(cmd, s.dest):
quit "invalid command: " & cmd
@ -267,6 +282,7 @@ proc runEpcTest(filename: string): int =
proc runTest(filename: string): int =
let s = parseTest filename
if s.skipDisabledTest: return 0
for cmd in s.startup:
if not runCmd(cmd, s.dest):
quit "invalid command: " & cmd