* Fixes #802, #803 and #3775 - genscript issues * Test case for genscript * Test script * Verify on Linux * Update categories.nim * Fix merge * Improve test framework * Windows fixes
This commit is contained in:
parent
b34580fd5b
commit
e931f3b5a9
8 changed files with 57 additions and 12 deletions
|
|
@ -652,6 +652,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
of "genscript", "gendeps":
|
of "genscript", "gendeps":
|
||||||
expectNoArg(switch, arg, pass, info)
|
expectNoArg(switch, arg, pass, info)
|
||||||
incl(gGlobalOptions, optGenScript)
|
incl(gGlobalOptions, optGenScript)
|
||||||
|
incl(gGlobalOptions, optCompileOnly)
|
||||||
of "colors": processOnOffSwitchG({optUseColors}, arg, pass, info)
|
of "colors": processOnOffSwitchG({optUseColors}, arg, pass, info)
|
||||||
of "lib":
|
of "lib":
|
||||||
expectArg(switch, arg, pass, info)
|
expectArg(switch, arg, pass, info)
|
||||||
|
|
|
||||||
|
|
@ -470,8 +470,9 @@ proc execExternalProgram*(cmd: string, msg = hintExecuting) =
|
||||||
|
|
||||||
proc generateScript(projectFile: string, script: Rope) =
|
proc generateScript(projectFile: string, script: Rope) =
|
||||||
let (dir, name, ext) = splitFile(projectFile)
|
let (dir, name, ext) = splitFile(projectFile)
|
||||||
writeRope(script, dir / addFileExt("compile_" & name,
|
writeRope(script, getNimcacheDir() / addFileExt("compile_" & name,
|
||||||
platform.OS[targetOS].scriptExt))
|
platform.OS[targetOS].scriptExt))
|
||||||
|
copyFile(libpath / "nimbase.h", getNimcacheDir() / "nimbase.h")
|
||||||
|
|
||||||
proc getOptSpeed(c: TSystemCC): string =
|
proc getOptSpeed(c: TSystemCC): string =
|
||||||
result = getConfigVar(c, ".options.speed")
|
result = getConfigVar(c, ".options.speed")
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@ Advanced options:
|
||||||
--noLinking compile Nim and generated files but do not link
|
--noLinking compile Nim and generated files but do not link
|
||||||
--noMain do not generate a main procedure
|
--noMain do not generate a main procedure
|
||||||
--genScript generate a compile script (in the 'nimcache'
|
--genScript generate a compile script (in the 'nimcache'
|
||||||
subdirectory named 'compile_$$project$$scriptext')
|
subdirectory named 'compile_$$project$$scriptext'),
|
||||||
|
implies --compileOnly
|
||||||
--genDeps generate a '.deps' file containing the dependencies
|
--genDeps generate a '.deps' file containing the dependencies
|
||||||
--os:SYMBOL set the target operating system (cross-compilation)
|
--os:SYMBOL set the target operating system (cross-compilation)
|
||||||
--cpu:SYMBOL set the target processor (cross-compilation)
|
--cpu:SYMBOL set the target processor (cross-compilation)
|
||||||
|
|
|
||||||
5
tests/flags/tgenscript.nim
Normal file
5
tests/flags/tgenscript.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
discard """
|
||||||
|
file: "tgenscript.nim"
|
||||||
|
"""
|
||||||
|
|
||||||
|
echo "--genscript"
|
||||||
|
|
@ -13,7 +13,7 @@ type
|
||||||
CommitId = distinct string
|
CommitId = distinct string
|
||||||
|
|
||||||
proc `$`*(id: MachineId): string {.borrow.}
|
proc `$`*(id: MachineId): string {.borrow.}
|
||||||
proc `$`(id: CommitId): string {.borrow.}
|
#proc `$`(id: CommitId): string {.borrow.} # not used
|
||||||
|
|
||||||
var
|
var
|
||||||
thisMachine: MachineId
|
thisMachine: MachineId
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,26 @@ proc compileRodFiles(r: var TResults, cat: Category, options: string) =
|
||||||
test "gtkex1", true
|
test "gtkex1", true
|
||||||
test "gtkex2"
|
test "gtkex2"
|
||||||
|
|
||||||
|
# --------------------- flags tests -------------------------------------------
|
||||||
|
|
||||||
|
proc flagTests(r: var TResults, cat: Category, options: string) =
|
||||||
|
# --genscript
|
||||||
|
const filename = "tests"/"flags"/"tgenscript"
|
||||||
|
const genopts = " --genscript"
|
||||||
|
let nimcache = nimcacheDir(filename, genopts, targetC)
|
||||||
|
testSpec r, makeTest(filename, genopts, cat)
|
||||||
|
|
||||||
|
when defined(windows):
|
||||||
|
testExec r, makeTest(filename, " cmd /c cd " & nimcache &
|
||||||
|
" && compile_tgenscript.bat", cat)
|
||||||
|
|
||||||
|
when defined(linux):
|
||||||
|
testExec r, makeTest(filename, " sh -c \"cd " & nimcache &
|
||||||
|
" && sh compile_tgenscript.sh\"", cat)
|
||||||
|
|
||||||
|
# Run
|
||||||
|
testExec r, makeTest(filename, " " & nimcache / "tgenscript", cat)
|
||||||
|
|
||||||
# --------------------- DLL generation tests ----------------------------------
|
# --------------------- DLL generation tests ----------------------------------
|
||||||
|
|
||||||
proc safeCopyFile(src, dest: string) =
|
proc safeCopyFile(src, dest: string) =
|
||||||
|
|
@ -323,7 +343,7 @@ var nimbleDir = getEnv("NIMBLE_DIR").string
|
||||||
if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble"
|
if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble"
|
||||||
let
|
let
|
||||||
nimbleExe = findExe("nimble")
|
nimbleExe = findExe("nimble")
|
||||||
packageDir = nimbleDir / "pkgs"
|
#packageDir = nimbleDir / "pkgs" # not used
|
||||||
packageIndex = nimbleDir / "packages.json"
|
packageIndex = nimbleDir / "packages.json"
|
||||||
|
|
||||||
proc waitForExitEx(p: Process): int =
|
proc waitForExitEx(p: Process): int =
|
||||||
|
|
@ -407,9 +427,9 @@ proc `&.?`(a, b: string): string =
|
||||||
# candidate for the stdlib?
|
# candidate for the stdlib?
|
||||||
result = if b.startswith(a): b else: a & b
|
result = if b.startswith(a): b else: a & b
|
||||||
|
|
||||||
proc `&?.`(a, b: string): string =
|
#proc `&?.`(a, b: string): string = # not used
|
||||||
# candidate for the stdlib?
|
# candidate for the stdlib?
|
||||||
result = if a.endswith(b): a else: a & b
|
#result = if a.endswith(b): a else: a & b
|
||||||
|
|
||||||
proc processSingleTest(r: var TResults, cat: Category, options, test: string) =
|
proc processSingleTest(r: var TResults, cat: Category, options, test: string) =
|
||||||
let test = "tests" & DirSep &.? cat.string / test
|
let test = "tests" & DirSep &.? cat.string / test
|
||||||
|
|
@ -429,6 +449,8 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
|
||||||
jsTests(r, cat, options)
|
jsTests(r, cat, options)
|
||||||
of "dll":
|
of "dll":
|
||||||
dllTests(r, cat, options)
|
dllTests(r, cat, options)
|
||||||
|
of "flags":
|
||||||
|
flagTests(r, cat, options)
|
||||||
of "gc":
|
of "gc":
|
||||||
gcTests(r, cat, options)
|
gcTests(r, cat, options)
|
||||||
of "longgc":
|
of "longgc":
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ proc generateAllTestsContent(outfile: File, allResults: AllTests,
|
||||||
|
|
||||||
proc generateHtml*(filename: string, onlyFailing: bool) =
|
proc generateHtml*(filename: string, onlyFailing: bool) =
|
||||||
let
|
let
|
||||||
currentTime = getTime().getLocalTime()
|
currentTime = getTime().local()
|
||||||
timestring = htmlQuote format(currentTime, "yyyy-MM-dd HH:mm:ss 'UTC'zzz")
|
timestring = htmlQuote format(currentTime, "yyyy-MM-dd HH:mm:ss 'UTC'zzz")
|
||||||
var outfile = open(filename, fmWrite)
|
var outfile = open(filename, fmWrite)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import
|
||||||
|
|
||||||
const
|
const
|
||||||
resultsFile = "testresults.html"
|
resultsFile = "testresults.html"
|
||||||
jsonFile = "testresults.json"
|
#jsonFile = "testresults.json" # not used
|
||||||
Usage = """Usage:
|
Usage = """Usage:
|
||||||
tester [options] command [arguments]
|
tester [options] command [arguments]
|
||||||
|
|
||||||
|
|
@ -150,11 +150,11 @@ proc initResults: TResults =
|
||||||
result.skipped = 0
|
result.skipped = 0
|
||||||
result.data = ""
|
result.data = ""
|
||||||
|
|
||||||
proc readResults(filename: string): TResults =
|
#proc readResults(filename: string): TResults = # not used
|
||||||
result = marshal.to[TResults](readFile(filename).string)
|
# result = marshal.to[TResults](readFile(filename).string)
|
||||||
|
|
||||||
proc writeResults(filename: string, r: TResults) =
|
#proc writeResults(filename: string, r: TResults) = # not used
|
||||||
writeFile(filename, $$r)
|
# writeFile(filename, $$r)
|
||||||
|
|
||||||
proc `$`(x: TResults): string =
|
proc `$`(x: TResults): string =
|
||||||
result = ("Tests passed: $1 / $3 <br />\n" &
|
result = ("Tests passed: $1 / $3 <br />\n" &
|
||||||
|
|
@ -404,6 +404,21 @@ proc testC(r: var TResults, test: TTest) =
|
||||||
if exitCode != 0: given.err = reExitCodesDiffer
|
if exitCode != 0: given.err = reExitCodesDiffer
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
|
|
||||||
|
proc testExec(r: var TResults, test: TTest) =
|
||||||
|
# runs executable or script, just goes by exit code
|
||||||
|
inc(r.total)
|
||||||
|
let (outp, errC) = execCmdEx(test.options.strip())
|
||||||
|
var given: TSpec
|
||||||
|
specDefaults(given)
|
||||||
|
if errC == 0:
|
||||||
|
given.err = reSuccess
|
||||||
|
else:
|
||||||
|
given.err = reExitCodesDiffer
|
||||||
|
given.msg = outp.string
|
||||||
|
|
||||||
|
if given.err == reSuccess: inc(r.passed)
|
||||||
|
r.addResult(test, targetC, "", given.msg, given.err)
|
||||||
|
|
||||||
proc makeTest(test, options: string, cat: Category, action = actionCompile,
|
proc makeTest(test, options: string, cat: Category, action = actionCompile,
|
||||||
env: string = ""): TTest =
|
env: string = ""): TTest =
|
||||||
# start with 'actionCompile', will be overwritten in the spec:
|
# start with 'actionCompile', will be overwritten in the spec:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue