test_merging.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. --
  2. -- tests/baking/test_merging.lua
  3. -- Verifies different field types are merged properly during baking.
  4. -- Copyright (c) 2011 Jason Perkins and the Premake project
  5. --
  6. T.baking_merging = { }
  7. local suite = T.baking_merging
  8. --
  9. -- Setup code
  10. --
  11. local sln, prj, cfg
  12. function suite.setup()
  13. sln = solution "MySolution"
  14. configurations { "Debug", "Release" }
  15. end
  16. local function prepare()
  17. premake.bake.buildconfigs()
  18. prj = premake.solution.getproject(sln, 1)
  19. end
  20. --
  21. -- String value tests
  22. --
  23. function suite.Strings_AreReplaced()
  24. kind "SharedLib"
  25. project "MyProject"
  26. kind "StaticLib"
  27. prepare()
  28. test.isequal("StaticLib", prj.kind)
  29. end
  30. function suite.Strings_KeepPreviousValue()
  31. kind "SharedLib"
  32. project "MyProject"
  33. prepare()
  34. test.isequal("SharedLib", prj.kind)
  35. end
  36. --
  37. -- List tests
  38. --
  39. function suite.Lists_KeepPreviousValue()
  40. project "MyProject"
  41. prepare()
  42. test.isequal("Debug:Release", table.concat(prj.configurations, ":"))
  43. end
  44. function suite.Lists_AreJoined()
  45. defines { "SOLUTION" }
  46. project "MyProject"
  47. defines { "PROJECT" }
  48. prepare()
  49. test.isequal("SOLUTION:PROJECT", table.concat(prj.defines, ":"))
  50. end
  51. function suite.Lists_RemoveDuplicates()
  52. defines { "SOLUTION", "DUPLICATE" }
  53. project "MyProject"
  54. defines { "PROJECT", "DUPLICATE" }
  55. prepare()
  56. test.isequal("SOLUTION:DUPLICATE:PROJECT", table.concat(prj.defines, ":"))
  57. end
  58. function suite.Lists_FlattensNestedTables()
  59. defines { "ROOT", { "NESTED" } }
  60. project "MyProject"
  61. prepare()
  62. test.isequal("ROOT:NESTED", table.concat(prj.defines, ":"))
  63. end
  64. --
  65. -- Key/value tests
  66. --
  67. function suite.KeyValue_AreMerged()
  68. vpaths { ["Solution"] = "*.sln" }
  69. project "MyProject"
  70. vpaths { ["Project"] = "*.prj" }
  71. prepare()
  72. test.isequal({"*.sln"}, prj.vpaths["Solution"])
  73. test.isequal({"*.prj"}, prj.vpaths["Project"])
  74. end
  75. function suite.KeyValue_MergesValues()
  76. vpaths { ["Solution"] = "*.sln", ["Project"] = "*.prj" }
  77. project "MyProject"
  78. vpaths { ["Project"] = "*.prjx" }
  79. prepare()
  80. test.isequal({"*.prj","*.prjx"}, prj.vpaths["Project"])
  81. end