premake4.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. --
  2. -- tests/premake4.lua
  3. -- Automated test suite for Premake 4.x
  4. -- Copyright (c) 2008-2011 Jason Perkins and the Premake project
  5. --
  6. dofile("testfx.lua")
  7. --
  8. -- Some helper functions
  9. --
  10. test.createsolution = function()
  11. local sln = solution "MySolution"
  12. configurations { "Debug", "Release" }
  13. local prj = project "MyProject"
  14. language "C++"
  15. kind "ConsoleApp"
  16. return sln, prj
  17. end
  18. test.createproject = function(sln)
  19. local n = #sln.projects + 1
  20. if n == 1 then n = "" end
  21. local prj = project ("MyProject" .. n)
  22. language "C++"
  23. kind "ConsoleApp"
  24. return prj
  25. end
  26. --
  27. -- The test suites
  28. --
  29. dofile("test_dofile.lua")
  30. dofile("test_string.lua")
  31. dofile("test_premake.lua")
  32. dofile("test_platforms.lua")
  33. dofile("test_targets.lua")
  34. dofile("test_keywords.lua")
  35. dofile("test_gmake_cpp.lua")
  36. dofile("test_gmake_cs.lua")
  37. dofile("base/test_api.lua")
  38. dofile("base/test_action.lua")
  39. dofile("base/test_config.lua")
  40. dofile("base/test_location.lua")
  41. dofile("base/test_os.lua")
  42. dofile("base/test_path.lua")
  43. dofile("base/test_premake_command.lua")
  44. dofile("base/test_table.lua")
  45. dofile("base/test_tree.lua")
  46. dofile("tools/test_gcc.lua")
  47. dofile("base/test_config_bug.lua")
  48. -- Project API tests
  49. dofile("test_project.lua")
  50. dofile("project/test_eachfile.lua")
  51. dofile("project/test_vpaths.lua")
  52. -- Baking tests
  53. dofile("base/test_baking.lua")
  54. dofile("baking/test_merging.lua")
  55. -- Clean tests
  56. dofile("actions/test_clean.lua")
  57. -- Visual Studio tests
  58. dofile("actions/vstudio/test_vs200x_vcproj.lua")
  59. dofile("actions/vstudio/test_vs200x_vcproj_linker.lua")
  60. dofile("actions/vstudio/test_vs2010_vcxproj.lua")
  61. dofile("actions/vstudio/test_vs2010_flags.lua")
  62. dofile("actions/vstudio/test_vs2010_project_kinds.lua")
  63. -- Visual Studio 2002-2003 C# projects
  64. dofile("actions/vstudio/cs2002/test_files.lua")
  65. -- Visual Studio 2005-2010 C# projects
  66. dofile("actions/vstudio/cs2005/test_files.lua")
  67. dofile("actions/vstudio/cs2005/projectelement.lua")
  68. dofile("actions/vstudio/cs2005/projectsettings.lua")
  69. dofile("actions/vstudio/cs2005/propertygroup.lua")
  70. -- Visual Studio 2005-2010 solutions
  71. dofile("actions/vstudio/sln2005/dependencies.lua")
  72. dofile("actions/vstudio/sln2005/header.lua")
  73. dofile("actions/vstudio/sln2005/layout.lua")
  74. dofile("actions/vstudio/sln2005/platforms.lua")
  75. dofile("actions/vstudio/sln2005/projectplatforms.lua")
  76. dofile("actions/vstudio/sln2005/projects.lua")
  77. -- Visual Studio 2002-2008 C/C++ projects
  78. dofile("actions/vstudio/vc200x/debugdir.lua")
  79. dofile("actions/vstudio/vc200x/header.lua")
  80. dofile("actions/vstudio/vc200x/test_files.lua")
  81. dofile("actions/vstudio/vc200x/test_filters.lua")
  82. -- Visual Studio 2010 C/C++ projects
  83. dofile("actions/vstudio/vc2010/test_config_props.lua")
  84. dofile("actions/vstudio/vc2010/test_debugdir.lua")
  85. dofile("actions/vstudio/vc2010/test_header.lua")
  86. dofile("actions/vstudio/vc2010/test_files.lua")
  87. dofile("actions/vstudio/vc2010/test_filters.lua")
  88. dofile("actions/vstudio/vc2010/test_link_settings.lua")
  89. dofile("actions/vstudio/vc2010/test_links.lua")
  90. dofile("actions/vstudio/vc2010/test_output_props.lua")
  91. dofile("actions/vstudio/vc2010/test_pch.lua")
  92. dofile("actions/vstudio/vc2010/test_project_refs.lua")
  93. -- Makefile tests
  94. dofile("actions/make/test_make_escaping.lua")
  95. dofile("actions/make/test_make_pch.lua")
  96. dofile("actions/make/test_make_linking.lua")
  97. -- dofile("actions/make/test_makesettings.lua")
  98. dofile("actions/make/test_wiidev.lua")
  99. --
  100. -- Register a test action
  101. --
  102. newoption {
  103. trigger = "test",
  104. description = "A suite or test to run"
  105. }
  106. newaction {
  107. trigger = "test",
  108. description = "Run the automated test suite",
  109. execute = function ()
  110. if _OPTIONS["test"] then
  111. local t = string.explode(_OPTIONS["test"] or "", ".", true)
  112. passed, failed = test.runall(t[1], t[2])
  113. else
  114. passed, failed = test.runall()
  115. end
  116. msg = string.format("%d tests passed, %d failed", passed, failed)
  117. if (failed > 0) then
  118. -- should probably return an error code here somehow
  119. print(msg)
  120. else
  121. print(msg)
  122. end
  123. end
  124. }