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