test_location.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. --
  2. -- tests/base/test_location.lua
  3. -- Automated tests for the location() function.
  4. -- Copyright (c) 2011 Jason Perkins and the Premake project
  5. --
  6. T.base_location = { }
  7. local suite = T.base_location
  8. --
  9. -- Setup/Teardown
  10. --
  11. function suite.setup()
  12. sln = solution "MySolution"
  13. configurations { "Debug", "Release" }
  14. language "C"
  15. end
  16. local function prepare()
  17. premake.bake.buildconfigs()
  18. prj = premake.solution.getproject(sln, 1)
  19. end
  20. --
  21. -- Test no location set
  22. --
  23. function suite.solutionUsesCwd_OnNoLocationSet()
  24. project "MyProject"
  25. prepare()
  26. test.isequal(os.getcwd(), sln.location)
  27. end
  28. function suite.projectUsesCwd_OnNoLocationSet()
  29. project "MyProject"
  30. prepare()
  31. test.isequal(os.getcwd(), prj.location)
  32. end
  33. --
  34. -- Test with location set on solution only
  35. --
  36. function suite.solutionUsesLocation_OnSolutionOnly()
  37. location "build"
  38. project "MyProject"
  39. prepare()
  40. test.isequal(path.join(os.getcwd(), "build"), sln.location)
  41. end
  42. function suite.projectUsesLocation_OnSolutionOnly()
  43. location "build"
  44. project "MyProject"
  45. prepare()
  46. test.isequal(path.join(os.getcwd(), "build"), prj.location)
  47. end
  48. --
  49. -- Test with location set on project only
  50. --
  51. function suite.solutionUsesCwd_OnProjectOnly()
  52. project "MyProject"
  53. location "build"
  54. prepare()
  55. test.isequal(os.getcwd(), sln.location)
  56. end
  57. function suite.projectUsesLocation_OnProjectOnly()
  58. project "MyProject"
  59. location "build"
  60. prepare()
  61. test.isequal(path.join(os.getcwd(), "build"), prj.location)
  62. end
  63. --
  64. -- Test with location set on both solution and project only
  65. --
  66. function suite.solutionUsesCwd_OnProjectOnly()
  67. location "build/solution"
  68. project "MyProject"
  69. location "build/project"
  70. prepare()
  71. test.isequal(path.join(os.getcwd(), "build/solution"), sln.location)
  72. end
  73. function suite.projectUsesLocation_OnProjectOnly()
  74. location "build/solution"
  75. project "MyProject"
  76. location "build/project"
  77. prepare()
  78. test.isequal(path.join(os.getcwd(), "build/project"), prj.location)
  79. end