Adds symbol proc run mode as suggested by Zahary.
To avoid collision each test case uses a different nimcache directory based on the input test filename.
This commit is contained in:
parent
10c441deed
commit
28041461b7
2 changed files with 17 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -167,6 +167,7 @@ examples/cross_calculator/android/tags
|
||||||
/run.json
|
/run.json
|
||||||
/testresults.html
|
/testresults.html
|
||||||
/testresults.json
|
/testresults.json
|
||||||
|
/tests/caas/SymbolProcRun.*/
|
||||||
/tests/caas/idetools_api
|
/tests/caas/idetools_api
|
||||||
/tests/caas/imported
|
/tests/caas/imported
|
||||||
/tests/caas/issue_416_template_shift
|
/tests/caas/issue_416_template_shift
|
||||||
|
|
@ -175,3 +176,4 @@ examples/cross_calculator/android/tags
|
||||||
/tests/caas/main
|
/tests/caas/main
|
||||||
/tests/caasdriver
|
/tests/caasdriver
|
||||||
/tools/nimgrep
|
/tools/nimgrep
|
||||||
|
no changes added to commit (use "git add" and/or "git commit -a")
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ import osproc, streams, os, strutils, re
|
||||||
|
|
||||||
type
|
type
|
||||||
TRunMode = enum
|
TRunMode = enum
|
||||||
ProcRun, CaasRun
|
ProcRun, CaasRun, SymbolProcRun
|
||||||
|
|
||||||
TNimrodSession* = object
|
TNimrodSession* = object
|
||||||
nim: PProcess # Holds the open process for CaasRun sessions, nil otherwise.
|
nim: PProcess # Holds the open process for CaasRun sessions, nil otherwise.
|
||||||
|
|
@ -53,9 +53,10 @@ type
|
||||||
lastOutput: string # Preserves the last output, needed for ProcRun mode.
|
lastOutput: string # Preserves the last output, needed for ProcRun mode.
|
||||||
filename: string # Appended to each command starting with '>'. Also a var.
|
filename: string # Appended to each command starting with '>'. Also a var.
|
||||||
modname: string # Like filename but without extension.
|
modname: string # Like filename but without extension.
|
||||||
|
nimcache: string # Input script based name for the nimcache dir.
|
||||||
|
|
||||||
const
|
const
|
||||||
modes = [CaasRun, ProcRun]
|
modes = [CaasRun, ProcRun, SymbolProcRun]
|
||||||
filenameReplaceVar = "$TESTNIM"
|
filenameReplaceVar = "$TESTNIM"
|
||||||
moduleReplaceVar = "$MODULE"
|
moduleReplaceVar = "$MODULE"
|
||||||
|
|
||||||
|
|
@ -67,12 +68,14 @@ proc replaceVars(session: var TNimrodSession, text: string): string =
|
||||||
result = text.replace(filenameReplaceVar, session.filename)
|
result = text.replace(filenameReplaceVar, session.filename)
|
||||||
result = result.replace(moduleReplaceVar, session.modname)
|
result = result.replace(moduleReplaceVar, session.modname)
|
||||||
|
|
||||||
proc startNimrodSession(project: string, mode: TRunMode): TNimrodSession =
|
proc startNimrodSession(project, script: string, mode: TRunMode):
|
||||||
|
TNimrodSession =
|
||||||
let (dir, name, ext) = project.splitFile
|
let (dir, name, ext) = project.splitFile
|
||||||
result.mode = mode
|
result.mode = mode
|
||||||
result.lastOutput = ""
|
result.lastOutput = ""
|
||||||
result.filename = name & ext
|
result.filename = name & ext
|
||||||
result.modname = name
|
result.modname = name
|
||||||
|
result.nimcache = "SymbolProcRun." & script.splitFile.name
|
||||||
if mode == CaasRun:
|
if mode == CaasRun:
|
||||||
result.nim = startProcess(NimrodBin, workingDir = dir,
|
result.nim = startProcess(NimrodBin, workingDir = dir,
|
||||||
args = ["serve", "--server.type:stdin", name])
|
args = ["serve", "--server.type:stdin", name])
|
||||||
|
|
@ -94,7 +97,7 @@ proc doCaasCommand(session: var TNimrodSession, command: string): string =
|
||||||
break
|
break
|
||||||
|
|
||||||
proc doProcCommand(session: var TNimrodSession, command: string): string =
|
proc doProcCommand(session: var TNimrodSession, command: string): string =
|
||||||
assert session.mode == ProcRun
|
assert session.mode == ProcRun or session.mode == SymbolProcRun
|
||||||
except: result = "FAILED TO EXECUTE: " & command & "\n" & result
|
except: result = "FAILED TO EXECUTE: " & command & "\n" & result
|
||||||
var
|
var
|
||||||
process = startProcess(NimrodBin, args = session.replaceVars(command).split)
|
process = startProcess(NimrodBin, args = session.replaceVars(command).split)
|
||||||
|
|
@ -113,6 +116,13 @@ proc doCommand(session: var TNimrodSession, command: string) =
|
||||||
session.lastOutput = doCaasCommand(session,
|
session.lastOutput = doCaasCommand(session,
|
||||||
command & " " & session.filename)
|
command & " " & session.filename)
|
||||||
else:
|
else:
|
||||||
|
var command = command
|
||||||
|
# For symbol runs we prepend the necessary parameters to avoid clobbering
|
||||||
|
# the normal nimcache.
|
||||||
|
if session.mode == SymbolProcRun:
|
||||||
|
command = "--symbolFiles:on --nimcache:" & session.nimcache &
|
||||||
|
" " & command
|
||||||
|
echo "Running ", command
|
||||||
session.lastOutput = doProcCommand(session,
|
session.lastOutput = doProcCommand(session,
|
||||||
command & " " & session.filename)
|
command & " " & session.filename)
|
||||||
|
|
||||||
|
|
@ -128,7 +138,7 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
|
||||||
|
|
||||||
if f.readLine(project):
|
if f.readLine(project):
|
||||||
var
|
var
|
||||||
s = startNimrodSession(script.parentDir / project.string, mode)
|
s = startNimrodSession(script.parentDir / project.string, script, mode)
|
||||||
tline = TaintedString("")
|
tline = TaintedString("")
|
||||||
ln = 1
|
ln = 1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue