summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/vm.nim3
-rw-r--r--compiler/vmdeps.nim9
-rw-r--r--tests/vm/tgorge.bat1
-rw-r--r--tests/vm/tgorge.nim12
-rwxr-xr-xtests/vm/tgorge.sh2
5 files changed, 23 insertions, 4 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index efcc55c59..d5acf5f73 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -1242,7 +1242,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
 
       createStr regs[ra]
       regs[ra].node.strVal = opGorge(regs[rb].node.strVal,
-                                     regs[rc].node.strVal, regs[rd].node.strVal)
+                                     regs[rc].node.strVal, regs[rd].node.strVal,
+                                     c.debug[pc])
     of opcNError:
       stackTrace(c, tos, pc, errUser, regs[ra].node.strVal)
     of opcNWarning:
diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim
index b40ca1058..3195294bd 100644
--- a/compiler/vmdeps.nim
+++ b/compiler/vmdeps.nim
@@ -19,7 +19,8 @@ proc readOutput(p: Process): string =
     result.setLen(result.len - "\n".len)
   discard p.waitForExit
 
-proc opGorge*(cmd, input, cache: string): string =
+proc opGorge*(cmd, input, cache: string, info: TLineInfo): string =
+  let workingDir = parentDir(info.toFullPath)
   if cache.len > 0:# and optForceFullMake notin gGlobalOptions:
     let h = secureHash(cmd & "\t" & input & "\t" & cache)
     let filename = options.toGeneratedFile("gorge_" & $h, "txt")
@@ -30,7 +31,8 @@ proc opGorge*(cmd, input, cache: string): string =
       return
     var readSuccessful = false
     try:
-      var p = startProcess(cmd, options={poEvalCommand, poStderrToStdout})
+      var p = startProcess(cmd, workingDir,
+                           options={poEvalCommand, poStderrToStdout})
       if input.len != 0:
         p.inputStream.write(input)
         p.inputStream.close()
@@ -41,7 +43,8 @@ proc opGorge*(cmd, input, cache: string): string =
       if not readSuccessful: result = ""
   else:
     try:
-      var p = startProcess(cmd, options={poEvalCommand, poStderrToStdout})
+      var p = startProcess(cmd, workingDir,
+                           options={poEvalCommand, poStderrToStdout})
       if input.len != 0:
         p.inputStream.write(input)
         p.inputStream.close()
diff --git a/tests/vm/tgorge.bat b/tests/vm/tgorge.bat
new file mode 100644
index 000000000..24d365842
--- /dev/null
+++ b/tests/vm/tgorge.bat
@@ -0,0 +1 @@
+@echo gorge test
\ No newline at end of file
diff --git a/tests/vm/tgorge.nim b/tests/vm/tgorge.nim
new file mode 100644
index 000000000..aeaf54df8
--- /dev/null
+++ b/tests/vm/tgorge.nim
@@ -0,0 +1,12 @@
+import os
+
+template getScriptDir(): string =
+  parentDir(instantiationInfo(-1, true).filename)
+
+const
+  execName = when defined(windows): "tgorge.bat" else: "./tgorge.sh"
+  relOutput = gorge(execName)
+  absOutput = gorge(getScriptDir() / execName)
+
+doAssert relOutput == "gorge test"
+doAssert absOutput == "gorge test"
\ No newline at end of file
diff --git a/tests/vm/tgorge.sh b/tests/vm/tgorge.sh
new file mode 100755
index 000000000..ba47afeae
--- /dev/null
+++ b/tests/vm/tgorge.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "gorge test"
\ No newline at end of file