add test for --eval; fix a minor bug (#16224)

This commit is contained in:
Timothee Cour
2020-12-01 21:09:08 -08:00
committed by GitHub
parent 9fa5826d62
commit 84f2ad3068
2 changed files with 7 additions and 0 deletions

View File

@@ -450,6 +450,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
conf.projectIsCmd = true
conf.cmdInput = arg # can be empty (a nim file with empty content is valid too)
if conf.cmd == cmdNone:
conf.command = "e"
conf.setCmd cmdNimscript # better than `cmdCrun` as a default
conf.implicitCmd = true
of "path", "p":

View File

@@ -216,3 +216,9 @@ mmain.html
let file = testsDir / "misc/mimportc.nim"
let cmd = fmt"{nim} r -b:cpp --hints:off --nimcache:{nimcache} --warningAsError:ProveInit {file}"
check execCmdEx(cmd) == ("witness\n", 0)
block: # nim --eval
let opt = "--hints:off"
check fmt"""{nim} {opt} --eval:"echo defined(nimscript)"""".execCmdEx == ("true\n", 0)
check fmt"""{nim} r {opt} --eval:"echo defined(c)"""".execCmdEx == ("true\n", 0)
check fmt"""{nim} r -b:js {opt} --eval:"echo defined(js)"""".execCmdEx == ("true\n", 0)