Add a few useful os calls to nimscript (#7442)

This commit is contained in:
genotrance 2018-04-10 11:50:23 -05:00 • committed by Andreas Rumpf
commit f6c8f97fe8
4 changed files with 81 additions and 2 deletions

View file

@ -30,4 +30,51 @@ putEnv("dummy", "myval")
doAssert(existsEnv("dummy") == true)
doAssert(getEnv("dummy") == "myval")
# issue #7393
let wd = getCurrentDir()
cd("..")
assert wd != getCurrentDir()
cd(wd)
assert wd == getCurrentDir()
assert findExe("nim") != ""
# general tests
mode = ScriptMode.Verbose
assert getCommand() == "c"
setCommand("cpp")
assert getCommand() == "cpp"
setCommand("c")
assert cmpic("HeLLO", "hello") == 0
assert fileExists("tests/newconfig/tfoo.nims") == true
assert dirExists("tests") == true
assert existsFile("tests/newconfig/tfoo.nims") == true
assert existsDir("tests") == true
discard selfExe()
when defined(windows):
assert toExe("nim") == "nim.exe"
assert toDll("nim") == "nim.dll"
else:
assert toExe("nim") == "nim"
assert toDll("nim") == "libnim.so"
rmDir("tempXYZ")
assert dirExists("tempXYZ") == false
mkDir("tempXYZ")
assert dirExists("tempXYZ") == true
assert fileExists("tempXYZ/koch.nim") == false
cpFile("koch.nim", "tempXYZ/koch.nim")
assert fileExists("tempXYZ/koch.nim") == true
cpDir("nimsuggest", "tempXYZ/.")
assert dirExists("tempXYZ/tests") == true
assert fileExists("tempXYZ/nimsuggest.nim") == true
rmFile("tempXYZ/koch.nim")
assert fileExists("tempXYZ/koch.nim") == false
rmDir("tempXYZ")
assert dirExists("tempXYZ") == false