test_baking.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. --
  2. -- tests/test_baking.lua
  3. -- Automated test suite for the configuration baking functions.
  4. -- Copyright (c) 2009, 2010 Jason Perkins and the Premake project
  5. --
  6. T.baking = { }
  7. local suite = T.baking
  8. --
  9. -- Setup code
  10. --
  11. local prj, cfg
  12. function suite.setup()
  13. _ACTION = "gmake"
  14. solution "MySolution"
  15. configurations { "Debug", "Release" }
  16. platforms { "x32", "ps3" }
  17. defines "SOLUTION"
  18. configuration "Debug"
  19. defines "SOLUTION_DEBUG"
  20. prj = project "MyProject"
  21. language "C"
  22. kind "SharedLib"
  23. targetdir "../bin"
  24. defines "PROJECT"
  25. configuration "Debug"
  26. defines "DEBUG"
  27. configuration "Release"
  28. defines "RELEASE"
  29. configuration "native"
  30. defines "NATIVE"
  31. configuration "x32"
  32. defines "X86_32"
  33. configuration "x64"
  34. defines "X86_64"
  35. end
  36. local function prepare()
  37. premake.bake.buildconfigs()
  38. prj = premake.getconfig(prj)
  39. cfg = premake.getconfig(prj, "Debug")
  40. end
  41. --
  42. -- Tests
  43. --
  44. function suite.ProjectWideSettings()
  45. prepare()
  46. test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(prj.defines,":"))
  47. end
  48. function suite.BuildCfgSettings()
  49. prepare()
  50. test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:NATIVE", table.concat(cfg.defines,":"))
  51. end
  52. function suite.PlatformSettings()
  53. prepare()
  54. local cfg = premake.getconfig(prj, "Debug", "x32")
  55. test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:X86_32", table.concat(cfg.defines,":"))
  56. end
  57. function suite.SetsConfigName()
  58. prepare()
  59. local cfg = premake.getconfig(prj, "Debug", "x32")
  60. test.isequal("Debug", cfg.name)
  61. end
  62. function suite.SetsPlatformName()
  63. prepare()
  64. local cfg = premake.getconfig(prj, "Debug", "x32")
  65. test.isequal("x32", cfg.platform)
  66. end
  67. function suite.SetsPlatformNativeName()
  68. test.isequal("Native", cfg.platform)
  69. end
  70. function suite.SetsShortName()
  71. prepare()
  72. local cfg = premake.getconfig(prj, "Debug", "x32")
  73. test.isequal("debug32", cfg.shortname)
  74. end
  75. function suite.SetsNativeShortName()
  76. prepare()
  77. test.isequal("debug", cfg.shortname)
  78. end
  79. function suite.SetsLongName()
  80. prepare()
  81. local cfg = premake.getconfig(prj, "Debug", "x32")
  82. test.isequal("Debug|x32", cfg.longname)
  83. end
  84. function suite.SetsNativeLongName()
  85. prepare()
  86. test.isequal("Debug", cfg.longname)
  87. end
  88. function suite.SetsProject()
  89. prepare()
  90. local cfg = premake.getconfig(prj, "Debug", "x32")
  91. test.istrue(prj.project == cfg.project)
  92. end
  93. --
  94. -- Target system testing
  95. --
  96. function suite.SetsTargetSystem_OnNative()
  97. prepare()
  98. test.isequal(os.get(), cfg.system)
  99. end
  100. function suite.SetTargetSystem_OnCrossCompiler()
  101. prepare()
  102. local cfg = premake.getconfig(prj, "Debug", "PS3")
  103. test.isequal("PS3", cfg.system)
  104. end
  105. --
  106. -- Configuration-specific kinds
  107. --
  108. function suite.SetsConfigSpecificKind()
  109. configuration "Debug"
  110. kind "ConsoleApp"
  111. prepare()
  112. test.isequal("ConsoleApp", cfg.kind)
  113. end
  114. --
  115. -- Platform kind translation
  116. --
  117. function suite.SetsTargetKind_OnSupportedKind()
  118. prepare()
  119. test.isequal("SharedLib", cfg.kind)
  120. end
  121. function suite.SetsTargetKind_OnUnsupportedKind()
  122. prepare()
  123. local cfg = premake.getconfig(prj, "Debug", "PS3")
  124. test.isequal("StaticLib", cfg.kind)
  125. end