test_include.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --
  2. -- tests/base/test_include.lua
  3. -- Test the include() function, for including external scripts
  4. -- Copyright (c) 2011-2014 Jason Perkins and the Premake project
  5. --
  6. local p = premake
  7. local suite = test.declare("include")
  8. --
  9. -- Setup and teardown
  10. --
  11. function suite.teardown()
  12. -- clear the list of included files after each run
  13. io._includedFiles = { }
  14. end
  15. --
  16. -- Tests
  17. --
  18. function suite.include_findsPremakeFile_onFolderNameOnly()
  19. include (_TESTS_DIR .. "/folder")
  20. test.isequal("ok", p.captured())
  21. end
  22. function suite.include_onExactFilename()
  23. include (_TESTS_DIR .. "/folder/premake5.lua")
  24. test.isequal("ok", p.captured())
  25. end
  26. function suite.include_runsOnlyOnce_onMultipleIncludes()
  27. include (_TESTS_DIR .. "/folder/premake5.lua")
  28. include (_TESTS_DIR .. "/folder/premake5.lua")
  29. test.isequal("ok", p.captured())
  30. end
  31. function suite.include_runsOnlyOnce_onMultipleIncludesWithDifferentPaths()
  32. include (_TESTS_DIR .. "/folder/premake5.lua")
  33. include (_TESTS_DIR .. "/../tests/folder/premake5.lua")
  34. test.isequal("ok", p.captured())
  35. end
  36. function suite.includeexternal_runs()
  37. includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
  38. test.isequal("ok", p.captured())
  39. end
  40. function suite.includeexternal_runsAfterInclude()
  41. include (_TESTS_DIR .. "/folder/premake5.lua")
  42. includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
  43. test.isequal("okok", p.captured())
  44. end
  45. function suite.includeexternal_runsTwiceAfterInclude()
  46. include (_TESTS_DIR .. "/folder/premake5.lua")
  47. includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
  48. includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
  49. test.isequal("okokok", p.captured())
  50. end