test_location.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --
  2. -- tests/project/test_location.lua
  3. -- Test handling of the projects's location field.
  4. -- Copyright (c) 2013 Jason Perkins and the Premake project
  5. --
  6. local suite = test.declare("project_location")
  7. --
  8. -- Setup and teardown
  9. --
  10. local wks, prj
  11. function suite.setup()
  12. wks = test.createWorkspace()
  13. end
  14. local function prepare()
  15. prj = test.getproject(wks, 1)
  16. end
  17. --
  18. -- If no explicit location is set, the location should be set to the
  19. -- directory containing the script which defined the project.
  20. --
  21. function suite.usesScriptLocation_onNoLocation()
  22. prepare()
  23. test.isequal(os.getcwd(), prj.location)
  24. end
  25. --
  26. -- If an explicit location has been set, use it.
  27. --
  28. function suite.usesLocation_onLocationSet()
  29. location "build"
  30. prepare()
  31. test.isequal(path.join(os.getcwd(), "build"), prj.location)
  32. end
  33. --
  34. -- If the workspace sets a location, and the project does not, it should
  35. -- inherit the value from the workspace.
  36. --
  37. function suite.inheritsWorkspaceLocation_onNoProjectLocation()
  38. workspace ()
  39. location "build"
  40. prepare()
  41. test.isequal(path.join(os.getcwd(), "build"), prj.location)
  42. end