ocarina/tests/Sconscript

61 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
import sys, os
Import("test_env")
res = []
def all_tests_enabled(dir):
for arg in sys.argv[1:]:
arg = os.path.normpath(arg)
name = os.path.basename(arg)
if (arg.find("tests") == 0) and (name == "tests"):
return True
if (arg.find("tests/%s" % dir) == 0) and (name == dir):
return True
return False
def add_test(test, dir):
global res
if (all_tests_enabled(dir) == True) and (len(res) > 0):
Depends(test, res[-1])
res += [ test ]
def get_test_obj(name, dir):
src = "../../%s/%s.cpp" % (dir, name)
if os.path.exists(src):
return test_env.Object("%s.cpp-%s" % (name, dir), src)
return None
test_lib = test_env.Object("test.cpp");
def generic_test(name, dir, objs, extra):
global test_obj;
obj = get_test_obj(name, dir)
test_objs = extra
if obj != None:
objs += [ obj ]
test_objs = extra + objs
exe = test_env.Program(name, [ "%s.cpp" % name, test_lib ] + test_objs)
test = Command("%s.fake" % name, [], "tests/%s/%s" % (dir, name))
Alias("tests/%s/%s" % (dir, name), test)
Depends(test, exe)
add_test(test, dir)
return objs
Export("get_test_obj", "generic_test")
test_env.UsePackage("glib-2.0")
exe = test_env.Program("sanity", [ "sanity.cpp", test_lib ])
test = Command("sanity.fake", [], "tests/sanity")
Alias("tests/sanity", test)
Depends(test, exe)
add_test(test, "")
SConscript("core/Sconscript")
Return("res")