diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/actions/test_clean.lua | 118 | ||||
-rw-r--r-- | tests/premake4.lua | 1 | ||||
-rw-r--r-- | tests/testfx.lua | 9 |
3 files changed, 127 insertions, 1 deletions
diff --git a/tests/actions/test_clean.lua b/tests/actions/test_clean.lua new file mode 100644 index 0000000..f6681ec --- /dev/null +++ b/tests/actions/test_clean.lua @@ -0,0 +1,118 @@ +-- +-- 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 callaction(name) + local action = premake.actions[name] + if action.execute then + action.execute() + end + end + + local function prepare() + premake.buildconfigs() + callaction("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.ObjectDirsAndFiles() + prj = project "MyProject" + language "C++" + kind "ConsoleApp" + prepare() + 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.elf") + test.contains(removed, "MyProject.vshost.exe") + test.contains(removed, "MyProject.exe.manifest") + end diff --git a/tests/premake4.lua b/tests/premake4.lua index aab750f..d047d85 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -25,6 +25,7 @@ dofile("test_vs200x_vcproj.lua") dofile("test_gmake_cpp.lua") dofile("test_gmake_cs.lua") + dofile("actions/test_clean.lua") -- diff --git a/tests/testfx.lua b/tests/testfx.lua index a135d52..ea04721 100644 --- a/tests/testfx.lua +++ b/tests/testfx.lua @@ -38,7 +38,14 @@ end end + + function test.contains(value, expected) + if not table.contains(value, expected) then + test.fail("expected value %s not found", expected) + end + end + function test.fail(format, ...) -- convert nils into something more usefuls for i = 1, arg.n do @@ -96,7 +103,7 @@ test.fail("expected true but was false") end end - + -- -- Define a collection for the test suites |