test_action.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --
  2. -- tests/base/test_action.lua
  3. -- Automated test suite for the action list.
  4. -- Copyright (c) 2009 Jason Perkins and the Premake project
  5. --
  6. T.action = { }
  7. --
  8. -- Setup/teardown
  9. --
  10. local fake = {
  11. trigger = "fake",
  12. description = "Fake action used for testing",
  13. }
  14. function T.action.setup()
  15. premake.action.list["fake"] = fake
  16. solution "MySolution"
  17. configurations "Debug"
  18. project "MyProject"
  19. premake.bake.buildconfigs()
  20. end
  21. function T.action.teardown()
  22. premake.action.list["fake"] = nil
  23. end
  24. --
  25. -- Tests for call()
  26. --
  27. function T.action.CallCallsExecuteIfPresent()
  28. local called = false
  29. fake.execute = function () called = true end
  30. premake.action.call("fake")
  31. test.istrue(called)
  32. end
  33. function T.action.CallCallsOnSolutionIfPresent()
  34. local called = false
  35. fake.onsolution = function () called = true end
  36. premake.action.call("fake")
  37. test.istrue(called)
  38. end
  39. function T.action.CallCallsOnProjectIfPresent()
  40. local called = false
  41. fake.onproject = function () called = true end
  42. premake.action.call("fake")
  43. test.istrue(called)
  44. end
  45. function T.action.CallSkipsCallbacksIfNotPresent()
  46. test.success(premake.action.call, "fake")
  47. end
  48. --
  49. -- Tests for set()
  50. --
  51. function T.action.set_SetsActionOS()
  52. local oldos = _OS
  53. _OS = "linux"
  54. premake.action.set("vs2008")
  55. test.isequal(_OS, "windows")
  56. _OS = oldos
  57. end