test_eachfile.lua 877 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --
  2. -- tests/project/test_eachfile.lua
  3. -- Automated test suite for the file iteration function.
  4. -- Copyright (c) 2011 Jason Perkins and the Premake project
  5. --
  6. T.project_eachfile = { }
  7. local suite = T.project_eachfile
  8. local project = premake.project
  9. --
  10. -- Setup and teardown
  11. --
  12. local sln, prj
  13. function suite.setup()
  14. sln = test.createsolution()
  15. end
  16. local function prepare()
  17. premake.bake.buildconfigs()
  18. prj = premake.solution.getproject(sln, 1)
  19. end
  20. --
  21. -- Tests
  22. --
  23. function suite.ReturnsAllFiles()
  24. files { "hello.h", "hello.c" }
  25. prepare()
  26. local iter = project.eachfile(prj)
  27. test.isequal("hello.h", iter().name)
  28. test.isequal("hello.c", iter().name)
  29. test.isnil(iter())
  30. end
  31. function suite.ReturnedObjectIncludesVpath()
  32. files { "hello.h", "hello.c" }
  33. prepare()
  34. local iter = project.eachfile(prj)
  35. test.isequal("hello.h", iter().vpath)
  36. end