tests: Rewrite how lib tests are run
Similar to how core tests were just rewritten, only applied to lib. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
7faa895b22
commit
89498ccc9e
|
@ -1,32 +1,62 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
Import("OTest", "TestList")
|
||||
import sys, os
|
||||
Import("test_env")
|
||||
|
||||
all = False
|
||||
for arg in sys.argv[1:]:
|
||||
arg = os.path.normpath(arg)
|
||||
name = os.path.basename(arg)
|
||||
if (arg.find("tests") == 0) and (name == "tests"):
|
||||
all = True
|
||||
if (arg.find("tests/lib") == 0) and (name == "lib"):
|
||||
all = True
|
||||
|
||||
res = []
|
||||
objs = []
|
||||
core = []
|
||||
|
||||
for f in Glob("../../core/*.cpp"):
|
||||
src = str(f).rsplit("/", 1)[1]
|
||||
core += [ OTest.Env.Object("%s-core" % src, str(f)) ]
|
||||
f = str(f)
|
||||
core += [ test_env.Object("%s-core" % os.path.basename(f), f) ]
|
||||
|
||||
|
||||
class LibTest(OTest):
|
||||
Objs = core
|
||||
def get_lib_obj(name):
|
||||
global objs
|
||||
if not os.path.exists("../../lib/%s.cpp" % name):
|
||||
return []
|
||||
objs += test_env.Object("%s.cpp-lib" % name, "../../lib/%s.cpp" % name)
|
||||
return objs
|
||||
|
||||
def __init__(self, src, pkg = None):
|
||||
OTest.__init__(self, src, pkg = pkg)
|
||||
def add_test(test):
|
||||
global all
|
||||
global res
|
||||
|
||||
def get_program(self):
|
||||
path = "../../lib/%s" % self.Src
|
||||
LibTest.Objs += [ LibTest.Env.Object("%s-lib" % self.Src, path) ]
|
||||
return OTest.Env.Program(self.Name, [ self.Src ] + LibTest.Objs)
|
||||
if (all == True) and (len(res) > 0):
|
||||
Depends(test, res[-1])
|
||||
res += [ test ]
|
||||
|
||||
def test(name):
|
||||
global core
|
||||
extra = get_lib_obj(name)
|
||||
exe = test_env.Program(name, [ "%s.cpp" % name ] + extra + core)
|
||||
test = Command("%s.fake" % name, [], "tests/lib/%s" % name);
|
||||
Alias("tests/lib/%s" % name, test)
|
||||
Depends(test, exe)
|
||||
add_test(test)
|
||||
|
||||
|
||||
res = TestList("lib", [
|
||||
|
||||
LibTest("lib.cpp", "gtkmm-3.0"),
|
||||
LibTest("colmgr.cpp"),
|
||||
LibTest("model.cpp"),
|
||||
###
|
||||
#
|
||||
# Test configuration starts here
|
||||
#
|
||||
|
||||
test( "lib" )
|
||||
|
||||
test_env.UsePackage("gtkmm-3.0")
|
||||
test( "colmgr" )
|
||||
test( "model" )
|
||||
|
||||
]).prepare()
|
||||
|
||||
Return("res")
|
||||
|
|
Loading…
Reference in New Issue