Merge pull request #2017 from reactormonk/nodejs-binary
Algorithm to find the nodejs binary
This commit is contained in:
commit
190cc01f24
4 changed files with 15 additions and 7 deletions
|
|
@ -15,7 +15,8 @@ when defined(gcc) and defined(windows):
|
||||||
|
|
||||||
import
|
import
|
||||||
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
||||||
extccomp, strutils, os, osproc, platform, main, parseopt, service
|
extccomp, strutils, os, osproc, platform, main, parseopt, service,
|
||||||
|
nodejs
|
||||||
|
|
||||||
when hasTinyCBackend:
|
when hasTinyCBackend:
|
||||||
import tccgen
|
import tccgen
|
||||||
|
|
@ -67,7 +68,7 @@ proc handleCmdLine() =
|
||||||
else:
|
else:
|
||||||
ex = quoteShell(
|
ex = quoteShell(
|
||||||
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
||||||
execExternalProgram("node " & ex & ' ' & commands.arguments)
|
execExternalProgram(findNodeJs() & " " & ex & ' ' & commands.arguments)
|
||||||
else:
|
else:
|
||||||
var binPath: string
|
var binPath: string
|
||||||
if options.outFile.len > 0:
|
if options.outFile.len > 0:
|
||||||
|
|
|
||||||
6
lib/pure/nodejs.nim
Normal file
6
lib/pure/nodejs.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
proc findNodeJs*(): string =
|
||||||
|
result = findExe("nodejs")
|
||||||
|
if result == "":
|
||||||
|
result = findExe("node")
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''
|
output: '''
|
||||||
WARNING: false first asseertion from bar
|
WARNING: false first assertion from bar
|
||||||
ERROR: false second assertion from bar
|
ERROR: false second assertion from bar
|
||||||
-1
|
-1
|
||||||
tfailedassert.nim:27 false assertion from foo
|
tfailedassert.nim:27 false assertion from foo
|
||||||
|
|
@ -31,7 +31,7 @@ proc bar: int =
|
||||||
# in this proc
|
# in this proc
|
||||||
onFailedAssert(msg): echo "WARNING: " & msg
|
onFailedAssert(msg): echo "WARNING: " & msg
|
||||||
|
|
||||||
assert(false, "first asseertion from bar")
|
assert(false, "first assertion from bar")
|
||||||
|
|
||||||
onFailedAssert(msg):
|
onFailedAssert(msg):
|
||||||
echo "ERROR: " & msg
|
echo "ERROR: " & msg
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
import
|
import
|
||||||
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
|
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
|
||||||
marshal, backend, parseopt, specs, htmlgen, browsers, terminal,
|
marshal, backend, parseopt, specs, htmlgen, browsers, terminal,
|
||||||
algorithm
|
algorithm, nodejs
|
||||||
|
|
||||||
const
|
const
|
||||||
resultsFile = "testresults.html"
|
resultsFile = "testresults.html"
|
||||||
|
|
@ -187,12 +187,13 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
else:
|
else:
|
||||||
exeFile = changeFileExt(tname, ExeExt)
|
exeFile = changeFileExt(tname, ExeExt)
|
||||||
if existsFile(exeFile):
|
if existsFile(exeFile):
|
||||||
if test.target == targetJS and findExe("nodejs") == "":
|
let nodejs = findNodeJs()
|
||||||
|
if test.target == targetJS and nodejs == "":
|
||||||
r.addResult(test, expected.outp, "nodejs binary not in PATH",
|
r.addResult(test, expected.outp, "nodejs binary not in PATH",
|
||||||
reExeNotFound)
|
reExeNotFound)
|
||||||
return
|
return
|
||||||
var (buf, exitCode) = execCmdEx(
|
var (buf, exitCode) = execCmdEx(
|
||||||
(if test.target == targetJS: "nodejs " else: "") & exeFile)
|
(if test.target == targetJS: nodejs & " " else: "") & exeFile)
|
||||||
if exitCode != expected.exitCode:
|
if exitCode != expected.exitCode:
|
||||||
r.addResult(test, "exitcode: " & $expected.exitCode,
|
r.addResult(test, "exitcode: " & $expected.exitCode,
|
||||||
"exitcode: " & $exitCode, reExitCodesDiffer)
|
"exitcode: " & $exitCode, reExitCodesDiffer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue