Fixes return values of execCmd on macos (#19963)
* Fixes return values of execCmd on macos * update tests to use existing structure Co-authored-by: daniel <danielclarke@wearepopgun.com>
This commit is contained in:
parent
7d0285853f
commit
01b40dc1d7
2 changed files with 14 additions and 1 deletions
|
|
@ -1523,7 +1523,7 @@ elif not defined(useNimRtl):
|
||||||
header: "<stdlib.h>".}
|
header: "<stdlib.h>".}
|
||||||
|
|
||||||
proc execCmd(command: string): int =
|
proc execCmd(command: string): int =
|
||||||
when defined(linux):
|
when defined(posix):
|
||||||
let tmp = csystem(command)
|
let tmp = csystem(command)
|
||||||
result = if tmp == -1: tmp else: exitStatusLikeShell(tmp)
|
result = if tmp == -1: tmp else: exitStatusLikeShell(tmp)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,12 @@ when defined(case_testfile): # compiled test file for child process
|
||||||
case arg
|
case arg
|
||||||
of "exit_0":
|
of "exit_0":
|
||||||
if true: quit(0)
|
if true: quit(0)
|
||||||
|
of "exit_1":
|
||||||
|
if true: quit(1)
|
||||||
|
of "exit_2":
|
||||||
|
if true: quit(2)
|
||||||
|
of "exit_42":
|
||||||
|
if true: quit(42)
|
||||||
of "exitnow_139":
|
of "exitnow_139":
|
||||||
if true: exitnow(139)
|
if true: exitnow(139)
|
||||||
of "c_exit2_139":
|
of "c_exit2_139":
|
||||||
|
|
@ -115,6 +121,13 @@ else: # main driver
|
||||||
runTest("c_exit2_139", 139)
|
runTest("c_exit2_139", 139)
|
||||||
runTest("quit_139", 139)
|
runTest("quit_139", 139)
|
||||||
|
|
||||||
|
block execCmdTest:
|
||||||
|
let output = compileNimProg("-d:release -d:case_testfile", "D20220705T221100")
|
||||||
|
doAssert execCmd(output & " exit_0") == 0
|
||||||
|
doAssert execCmd(output & " exit_1") == 1
|
||||||
|
doAssert execCmd(output & " exit_2") == 2
|
||||||
|
doAssert execCmd(output & " exit_42") == 42
|
||||||
|
|
||||||
import std/streams
|
import std/streams
|
||||||
|
|
||||||
block execProcessTest:
|
block execProcessTest:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue