summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorGrzegorz Adam Hankiewicz <gradha@imap.cc>2013-06-11 17:23:48 +0200
committerGrzegorz Adam Hankiewicz <gradha@imap.cc>2013-06-11 17:23:48 +0200
commit28041461b7366433c22acc8257c9a5e8a0bd3b40 (patch)
treee0ba521a00d37730bcf33bb8b4cfc86c1cff7392
parent10c441deed6b9ee176f59ef3ee015f99a54c4f46 (diff)
downloadNim-28041461b7366433c22acc8257c9a5e8a0bd3b40.tar.gz
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.
-rw-r--r--.gitignore2
-rw-r--r--tests/caasdriver.nim20
2 files changed, 17 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index eb2e27e9e..a52319eff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -167,6 +167,7 @@ examples/cross_calculator/android/tags
 /run.json
 /testresults.html
 /testresults.json
+/tests/caas/SymbolProcRun.*/
 /tests/caas/idetools_api
 /tests/caas/imported
 /tests/caas/issue_416_template_shift
@@ -175,3 +176,4 @@ examples/cross_calculator/android/tags
 /tests/caas/main
 /tests/caasdriver
 /tools/nimgrep
+no changes added to commit (use "git add" and/or "git commit -a")
diff --git a/tests/caasdriver.nim b/tests/caasdriver.nim
index d4838dc39..619ce9b6a 100644
--- a/tests/caasdriver.nim
+++ b/tests/caasdriver.nim
@@ -45,7 +45,7 @@ import osproc, streams, os, strutils, re
 
 type
   TRunMode = enum
-    ProcRun, CaasRun
+    ProcRun, CaasRun, SymbolProcRun
 
   TNimrodSession* = object
     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.
     filename: string # Appended to each command starting with '>'. Also a var.
     modname: string # Like filename but without extension.
+    nimcache: string # Input script based name for the nimcache dir.
 
 const
-  modes = [CaasRun, ProcRun]
+  modes = [CaasRun, ProcRun, SymbolProcRun]
   filenameReplaceVar = "$TESTNIM"
   moduleReplaceVar = "$MODULE"
 
@@ -67,12 +68,14 @@ proc replaceVars(session: var TNimrodSession, text: string): string =
   result = text.replace(filenameReplaceVar, session.filename)
   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
   result.mode = mode
   result.lastOutput = ""
   result.filename = name & ext
   result.modname = name
+  result.nimcache = "SymbolProcRun." & script.splitFile.name
   if mode == CaasRun:
     result.nim = startProcess(NimrodBin, workingDir = dir,
       args = ["serve", "--server.type:stdin", name])
@@ -94,7 +97,7 @@ proc doCaasCommand(session: var TNimrodSession, command: string): string =
       break
 
 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
   var
     process = startProcess(NimrodBin, args = session.replaceVars(command).split)
@@ -113,6 +116,13 @@ proc doCommand(session: var TNimrodSession, command: string) =
     session.lastOutput = doCaasCommand(session,
                                        command & " " & session.filename)
   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,
                                        command & " " & session.filename)
 
@@ -128,7 +138,7 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
 
   if f.readLine(project):
     var
-      s = startNimrodSession(script.parentDir / project.string, mode)
+      s = startNimrodSession(script.parentDir / project.string, script, mode)
       tline = TaintedString("")
       ln = 1