test_clean.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. --
  2. -- tests/actions/test_clean.lua
  3. -- Automated test suite for the "clean" action.
  4. -- Copyright (c) 2009 Jason Perkins and the Premake project
  5. --
  6. T.clean = { }
  7. --
  8. -- Replacement functions for remove() and rmdir() for testing
  9. --
  10. local os_remove, os_rmdir, cwd
  11. local removed
  12. local function test_remove(fn)
  13. if not cwd then cwd = os.getcwd() end
  14. table.insert(removed, path.getrelative(cwd, fn))
  15. end
  16. --
  17. -- Setup/teardown
  18. --
  19. local sln
  20. function T.clean.setup()
  21. _ACTION = "clean"
  22. os_remove = os.remove
  23. os_rmdir = os.rmdir
  24. os.remove = test_remove
  25. os.rmdir = test_remove
  26. removed = {}
  27. sln = solution "MySolution"
  28. configurations { "Debug", "Release" }
  29. end
  30. function T.clean.teardown()
  31. os.remove = os_remove
  32. os.rmdir = os_rmdir
  33. end
  34. local function prepare()
  35. premake.bake.buildconfigs()
  36. premake.action.call("clean")
  37. end
  38. --
  39. -- Tests
  40. --
  41. function T.clean.SolutionFiles()
  42. prepare()
  43. test.contains(removed, "MySolution.sln")
  44. test.contains(removed, "MySolution.suo")
  45. test.contains(removed, "MySolution.ncb")
  46. test.contains(removed, "MySolution.userprefs")
  47. test.contains(removed, "MySolution.usertasks")
  48. test.contains(removed, "MySolution.workspace")
  49. test.contains(removed, "MySolution_wsp.mk")
  50. test.contains(removed, "MySolution.tags")
  51. test.contains(removed, "Makefile")
  52. end
  53. function T.clean.CppProjectFiles()
  54. prj = project "MyProject"
  55. language "C++"
  56. kind "ConsoleApp"
  57. prepare()
  58. test.contains(removed, "MyProject.vcproj")
  59. test.contains(removed, "MyProject.pdb")
  60. test.contains(removed, "MyProject.idb")
  61. test.contains(removed, "MyProject.ilk")
  62. test.contains(removed, "MyProject.cbp")
  63. test.contains(removed, "MyProject.depend")
  64. test.contains(removed, "MyProject.layout")
  65. test.contains(removed, "MyProject.mk")
  66. test.contains(removed, "MyProject.list")
  67. test.contains(removed, "MyProject.out")
  68. test.contains(removed, "MyProject.make")
  69. end
  70. function T.clean.CsProjectFiles()
  71. prj = project "MyProject"
  72. language "C#"
  73. kind "ConsoleApp"
  74. prepare()
  75. test.contains(removed, "MyProject.csproj")
  76. test.contains(removed, "MyProject.csproj.user")
  77. test.contains(removed, "MyProject.pdb")
  78. test.contains(removed, "MyProject.idb")
  79. test.contains(removed, "MyProject.ilk")
  80. test.contains(removed, "MyProject.make")
  81. end
  82. function T.clean.ObjectDirsAndFiles()
  83. prj = project "MyProject"
  84. language "C++"
  85. kind "ConsoleApp"
  86. prepare()
  87. test.contains(removed, "obj/Debug")
  88. test.contains(removed, "obj/Release")
  89. end
  90. function T.clean.CppConsoleAppFiles()
  91. prj = project "MyProject"
  92. language "C++"
  93. kind "ConsoleApp"
  94. prepare()
  95. test.contains(removed, "MyProject")
  96. test.contains(removed, "MyProject.exe")
  97. test.contains(removed, "MyProject.elf")
  98. test.contains(removed, "MyProject.vshost.exe")
  99. test.contains(removed, "MyProject.exe.manifest")
  100. end
  101. function T.clean.CppWindowedAppFiles()
  102. prj = project "MyProject"
  103. language "C++"
  104. kind "WindowedApp"
  105. prepare()
  106. test.contains(removed, "MyProject")
  107. test.contains(removed, "MyProject.exe")
  108. test.contains(removed, "MyProject.app")
  109. end
  110. function T.clean.CppSharedLibFiles()
  111. prj = project "MyProject"
  112. language "C++"
  113. kind "SharedLib"
  114. prepare()
  115. test.contains(removed, "MyProject.dll")
  116. test.contains(removed, "libMyProject.so")
  117. test.contains(removed, "MyProject.lib")
  118. test.contains(removed, "libMyProject.dylib")
  119. end
  120. function T.clean.CppBundleFiles()
  121. prj = project "MyProject"
  122. language "C++"
  123. kind "Bundle"
  124. prepare()
  125. test.contains(removed, "MyProject.dll")
  126. test.contains(removed, "libMyProject.so")
  127. test.contains(removed, "MyProject.lib")
  128. test.contains(removed, "MyProject.bundle")
  129. end
  130. function T.clean.CppStaticLibFiles()
  131. prj = project "MyProject"
  132. language "C++"
  133. kind "StaticLib"
  134. prepare()
  135. test.contains(removed, "MyProject.lib")
  136. test.contains(removed, "libMyProject.a")
  137. end
  138. function T.clean.PlatformObjects()
  139. platforms { "Native", "x32" }
  140. prj = project "MyProject"
  141. language "C++"
  142. kind "ConsoleApp"
  143. prepare()
  144. test.contains(removed, "obj/Debug")
  145. test.contains(removed, "obj/Release")
  146. test.contains(removed, "obj/x32/Debug")
  147. test.contains(removed, "obj/x32/Release")
  148. end
  149. function T.clean.CppConsoleAppFiles_OnSuffix()
  150. prj = project "MyProject"
  151. language "C++"
  152. kind "ConsoleApp"
  153. targetsuffix "_x"
  154. prepare()
  155. test.contains(removed, "MyProject_x")
  156. test.contains(removed, "MyProject_x.exe")
  157. test.contains(removed, "MyProject_x.elf")
  158. test.contains(removed, "MyProject_x.vshost.exe")
  159. test.contains(removed, "MyProject_x.exe.manifest")
  160. end