tfoo.nims 2.5 KB

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