This commit is contained in:
Felix Krause 2016-10-09 18:02:48 +02:00
commit 39f03d816c
5 changed files with 23 additions and 4 deletions

View file

@ -1242,7 +1242,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
createStr regs[ra] createStr regs[ra]
regs[ra].node.strVal = opGorge(regs[rb].node.strVal, 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: of opcNError:
stackTrace(c, tos, pc, errUser, regs[ra].node.strVal) stackTrace(c, tos, pc, errUser, regs[ra].node.strVal)
of opcNWarning: of opcNWarning:

View file

@ -19,7 +19,8 @@ proc readOutput(p: Process): string =
result.setLen(result.len - "\n".len) result.setLen(result.len - "\n".len)
discard p.waitForExit 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: if cache.len > 0:# and optForceFullMake notin gGlobalOptions:
let h = secureHash(cmd & "\t" & input & "\t" & cache) let h = secureHash(cmd & "\t" & input & "\t" & cache)
let filename = options.toGeneratedFile("gorge_" & $h, "txt") let filename = options.toGeneratedFile("gorge_" & $h, "txt")
@ -30,7 +31,8 @@ proc opGorge*(cmd, input, cache: string): string =
return return
var readSuccessful = false var readSuccessful = false
try: try:
var p = startProcess(cmd, options={poEvalCommand, poStderrToStdout}) var p = startProcess(cmd, workingDir,
options={poEvalCommand, poStderrToStdout})
if input.len != 0: if input.len != 0:
p.inputStream.write(input) p.inputStream.write(input)
p.inputStream.close() p.inputStream.close()
@ -41,7 +43,8 @@ proc opGorge*(cmd, input, cache: string): string =
if not readSuccessful: result = "" if not readSuccessful: result = ""
else: else:
try: try:
var p = startProcess(cmd, options={poEvalCommand, poStderrToStdout}) var p = startProcess(cmd, workingDir,
options={poEvalCommand, poStderrToStdout})
if input.len != 0: if input.len != 0:
p.inputStream.write(input) p.inputStream.write(input)
p.inputStream.close() p.inputStream.close()

1
tests/vm/tgorge.bat Normal file
View file

@ -0,0 +1 @@
@echo gorge test

12
tests/vm/tgorge.nim Normal file
View file

@ -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"

2
tests/vm/tgorge.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
echo "gorge test"