2013-07-05 09:40:11 -04:00
|
|
|
#!/usr/bin/python
|
2014-05-14 17:48:43 -04:00
|
|
|
import sys, os
|
|
|
|
Import("test_env")
|
2014-06-14 10:50:18 -04:00
|
|
|
|
2014-11-01 14:39:30 -04:00
|
|
|
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
|
|
|
|
|
2015-01-04 17:56:54 -05:00
|
|
|
test_lib = test_env.Object("test.cpp");
|
|
|
|
|
2014-11-01 14:39:30 -04:00
|
|
|
def generic_test(name, dir, objs, extra):
|
2015-01-04 17:56:54 -05:00
|
|
|
global test_obj;
|
2014-11-01 14:39:30 -04:00
|
|
|
obj = get_test_obj(name, dir)
|
2014-11-01 19:45:39 -04:00
|
|
|
test_objs = extra
|
2014-11-01 14:39:30 -04:00
|
|
|
if obj != None:
|
|
|
|
objs += [ obj ]
|
|
|
|
test_objs = extra + objs
|
|
|
|
|
2015-01-04 17:56:54 -05:00
|
|
|
exe = test_env.Program(name, [ "%s.cpp" % name, test_lib ] + test_objs)
|
2015-01-02 10:31:32 -05:00
|
|
|
test = Command("%s.fake" % name, [], "tests/%s/%s" % (dir, name))
|
2014-11-01 19:45:39 -04:00
|
|
|
|
2014-11-01 14:39:30 -04:00
|
|
|
Alias("tests/%s/%s" % (dir, name), test)
|
|
|
|
Depends(test, exe)
|
|
|
|
add_test(test, dir)
|
|
|
|
return objs
|
|
|
|
|
2014-05-06 08:36:11 -04:00
|
|
|
|
2014-11-01 14:39:30 -04:00
|
|
|
Export("get_test_obj", "generic_test")
|
2014-03-02 14:44:24 -05:00
|
|
|
|
2015-01-04 17:56:54 -05:00
|
|
|
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, "")
|
|
|
|
|
|
|
|
|
2014-11-01 19:45:39 -04:00
|
|
|
SConscript("core/Sconscript")
|
2014-06-14 10:50:18 -04:00
|
|
|
|
|
|
|
Return("res")
|