tfoo.nims 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. mode = ScriptMode.Whatif
  2. exec "gcc -v"
  3. --forceBuild
  4. --path: "../friends"
  5. warning("uninit", off)
  6. block: # supported syntaxes for hint,warning,switch
  7. --hint:processing
  8. hint("processing", on)
  9. hint("processing", off)
  10. switch("hint", "processing")
  11. switch("hint", "processing:on")
  12. switch("hint", "processing:off")
  13. switch("hint", "[processing]")
  14. switch("hint", "[processing]:on")
  15. switch("hint", "[processing]:off") # leave it off
  16. --warning:UnusedImport
  17. switch("warning", "UnusedImport:off")
  18. switch("warning", "UnusedImport:on")
  19. switch("warning", "[UnusedImport]:off")
  20. switch("warning", "[UnusedImport]:on")
  21. switch("warning", "[UnusedImport]")
  22. switch("warning", "UnusedImport") # leave it on
  23. #--verbosity:2
  24. patchFile("stdlib", "math", "mymath")
  25. task listDirs, "lists every subdirectory":
  26. for x in listDirs("."):
  27. echo "DIR ", x
  28. task default, "default target":
  29. --define: definedefine
  30. setCommand "c"
  31. # bug #6327
  32. doAssert(existsEnv("dummy") == false)
  33. # issue #7283
  34. putEnv("dummy", "myval")
  35. doAssert(existsEnv("dummy"))
  36. doAssert(getEnv("dummy") == "myval")
  37. delEnv("dummy")
  38. doAssert(existsEnv("dummy") == false)
  39. # issue #7393
  40. let wd = getCurrentDir()
  41. cd("..")
  42. assert wd != getCurrentDir()
  43. cd(wd)
  44. assert wd == getCurrentDir()
  45. when false:
  46. # this doesn't work in a 'koch testintall' environment
  47. assert findExe("nim") != ""
  48. # general tests
  49. mode = ScriptMode.Verbose
  50. assert getCommand() == "c"
  51. setCommand("cpp")
  52. assert getCommand() == "cpp"
  53. setCommand("c")
  54. assert cmpic("HeLLO", "hello") == 0
  55. assert fileExists("tests/newconfig/tfoo.nims") == true
  56. assert dirExists("tests") == true
  57. assert fileExists("tests/newconfig/tfoo.nims") == true
  58. assert dirExists("tests") == true
  59. discard selfExe()
  60. when defined(windows):
  61. assert toExe("nim") == "nim.exe"
  62. assert toDll("nim") == "nim.dll"
  63. else:
  64. assert toExe("nim") == "nim"
  65. assert toDll("nim") == "libnim.so"
  66. rmDir("tempXYZ")
  67. doAssertRaises(OSError):
  68. rmDir("tempXYZ", checkDir = true)
  69. assert dirExists("tempXYZ") == false
  70. mkDir("tempXYZ")
  71. assert dirExists("tempXYZ") == true
  72. assert fileExists("tempXYZ/koch.nim") == false
  73. when false:
  74. # this doesn't work in a 'koch testintall' environment
  75. cpFile("koch.nim", "tempXYZ/koch.nim")
  76. assert fileExists("tempXYZ/koch.nim") == true
  77. cpDir("nimsuggest", "tempXYZ/.")
  78. assert dirExists("tempXYZ/tests") == true
  79. assert fileExists("tempXYZ/nimsuggest.nim") == true
  80. rmFile("tempXYZ/koch.nim")
  81. assert fileExists("tempXYZ/koch.nim") == false
  82. rmDir("tempXYZ")
  83. assert dirExists("tempXYZ") == false