mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
@@ -87,8 +87,9 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) =
|
||||
var hcri = makeTest("tests/dll/nimhcr_integration.nim",
|
||||
options & " --forceBuild --hotCodeReloading:on" & rpath, cat)
|
||||
let nimcache = nimcacheDir(hcri.name, hcri.options, getTestSpecTarget())
|
||||
hcri.args = prepareTestArgs(hcri.spec.getCmd, hcri.name,
|
||||
let cmd = prepareTestCmd(hcri.spec.getCmd, hcri.name,
|
||||
hcri.options, nimcache, getTestSpecTarget())
|
||||
hcri.testArgs = cmd.parseCmdLine
|
||||
testSpec r, hcri
|
||||
|
||||
proc dllTests(r: var TResults, cat: Category, options: string) =
|
||||
|
||||
@@ -85,7 +85,7 @@ type
|
||||
name: string
|
||||
cat: Category
|
||||
options: string
|
||||
args: seq[string]
|
||||
testArgs: seq[string]
|
||||
spec: TSpec
|
||||
startTime: float
|
||||
debugInfo: string
|
||||
@@ -154,24 +154,23 @@ proc nimcacheDir(filename, options: string, target: TTarget): string =
|
||||
let hashInput = options & $target
|
||||
result = "nimcache" / (filename & '_' & hashInput.getMD5)
|
||||
|
||||
proc prepareTestArgs(cmdTemplate, filename, options, nimcache: string,
|
||||
target: TTarget, extraOptions = ""): seq[string] =
|
||||
proc prepareTestCmd(cmdTemplate, filename, options, nimcache: string,
|
||||
target: TTarget, extraOptions = ""): string =
|
||||
var options = target.defaultOptions & ' ' & options
|
||||
# improve pending https://github.com/nim-lang/Nim/issues/14343
|
||||
if nimcache.len > 0: options.add ' ' & ("--nimCache:" & nimcache).quoteShell
|
||||
if nimcache.len > 0: options.add(" --nimCache:$#" % nimcache.quoteShell)
|
||||
options.add ' ' & extraOptions
|
||||
result = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||
# we avoid using `parseCmdLine` which is buggy, refs bug #14343
|
||||
result = cmdTemplate % ["target", targetToCmd[target],
|
||||
"options", options, "file", filename.quoteShell,
|
||||
"filedir", filename.getFileDir(), "nim", compilerPrefix])
|
||||
"filedir", filename.getFileDir(), "nim", compilerPrefix]
|
||||
|
||||
proc callNimCompiler(cmdTemplate, filename, options, nimcache: string,
|
||||
target: TTarget, extraOptions = ""): TSpec =
|
||||
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache, target,
|
||||
result.cmd = prepareTestCmd(cmdTemplate, filename, options, nimcache, target,
|
||||
extraOptions)
|
||||
result.cmd = quoteShellCommand(c)
|
||||
verboseCmd(c.quoteShellCommand)
|
||||
var p = startProcess(command = c[0], args = c[1 .. ^1],
|
||||
options = {poStdErrToStdOut, poUsePath})
|
||||
verboseCmd(result.cmd)
|
||||
var p = startProcess(command = result.cmd,
|
||||
options = {poStdErrToStdOut, poUsePath, poEvalCommand})
|
||||
let outp = p.outputStream
|
||||
var foundSuccessMsg = false
|
||||
var foundErrorMsg = false
|
||||
@@ -224,9 +223,33 @@ proc callNimCompiler(cmdTemplate, filename, options, nimcache: string,
|
||||
|
||||
proc callCCompiler(cmdTemplate, filename, options: string,
|
||||
target: TTarget): TSpec =
|
||||
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache = "", target)
|
||||
let cmd = prepareTestCmd(cmdTemplate, filename, options, nimcache = "", target)
|
||||
doAssert false
|
||||
#[
|
||||
this code hasn't been run in a while, and should be removed which simplifies code
|
||||
there are better ways to do this anyways (e.g. running c code from a nim file)
|
||||
|
||||
the only place where this is called is:
|
||||
`testC r, makeTest("tests/realtimeGC/cmain", cOptions, cat), actionRun`
|
||||
which isn't run unless you call:
|
||||
XDG_CONFIG_HOME= nim r --lib:lib --stacktrace:on testament/testament.nim r longgc
|
||||
|
||||
and this fails since at least nim 1.0 with:
|
||||
testament/testament.nim(851) testament
|
||||
testament/testament.nim(822) main
|
||||
testament/categories.nim(713) processCategory
|
||||
testament/categories.nim(189) longGCTests
|
||||
testament/testament.nim(644) makeTest
|
||||
testament/specs.nim(251) parseSpec
|
||||
testament/specs.nim(184) extractSpec
|
||||
lib/system/io.nim(861) readFile
|
||||
Error: unhandled exception: cannot open: tests/realtimeGC/cmain.nim [IOError]
|
||||
|
||||
Also, `c[5 .. ^1]` is too magical.
|
||||
]#
|
||||
let c = cmd.parseCmdLine
|
||||
var p = startProcess(command = "gcc", args = c[5 .. ^1],
|
||||
options = {poStdErrToStdOut, poUsePath})
|
||||
options = {poStdErrToStdOut, poUsePath, poEvalCommand})
|
||||
let outp = p.outputStream
|
||||
var x = newStringOfCap(120)
|
||||
result.nimout = ""
|
||||
@@ -525,7 +548,7 @@ proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec,
|
||||
reExeNotFound)
|
||||
else:
|
||||
var exeCmd: string
|
||||
var args = test.args
|
||||
var args = test.testArgs
|
||||
if isJsTarget:
|
||||
exeCmd = nodejs
|
||||
# see D20210217T215950
|
||||
|
||||
21
tests/misc/t18077.nim
Normal file
21
tests/misc/t18077.nim
Normal file
@@ -0,0 +1,21 @@
|
||||
discard """
|
||||
cmd: '''nim doc -d:nimTestsT18077b:4 --doccmd:"-d:nimTestsT18077 -d:nimTestsT18077b:3 --hints:off" $file'''
|
||||
action: compile
|
||||
"""
|
||||
|
||||
# bug #18077
|
||||
|
||||
const nimTestsT18077b {.intdefine.} = 1
|
||||
|
||||
static:
|
||||
when defined(nimdoc):
|
||||
doAssert nimTestsT18077b == 4
|
||||
doAssert not defined(nimTestsT18077)
|
||||
else:
|
||||
doAssert defined(nimTestsT18077)
|
||||
doAssert nimTestsT18077b == 3
|
||||
|
||||
runnableExamples:
|
||||
const nimTestsT18077b {.intdefine.} = 2
|
||||
doAssert nimTestsT18077b == 3
|
||||
doAssert defined(nimTestsT18077)
|
||||
Reference in New Issue
Block a user