diff --git a/Sconstruct b/Sconstruct index e6fc9787..9d464c34 100644 --- a/Sconstruct +++ b/Sconstruct @@ -23,8 +23,7 @@ class OEnvironment(Environment): self.ParseConfig("pkg-config --cflags --libs %s" % name) env = OEnvironment() -test_env = OEnvironment( CONFIG_CCFLAGS + [ "-DCONFIG_TEST" ] ) -Export("env", "test_env") +Export("env") include = SConscript("include/Sconscript") diff --git a/include/Sconscript b/include/Sconscript index d8d44890..dd1d5a03 100644 --- a/include/Sconscript +++ b/include/Sconscript @@ -1,6 +1,6 @@ #!/usr/bin/python import subprocess -Import("env", "test_env") +Import("env") version = str(env.Version) if env.Debug == True: @@ -15,5 +15,4 @@ try: except: pass -for e in (env, test_env): - e.Append( CCFLAGS = [ "-DCONFIG_VERSION='\"%s\"'" % version ] ) +env.Append( CCFLAGS = [ "-DCONFIG_VERSION='\"%s\"'" % version ] ) diff --git a/tests/Sconscript b/tests/Sconscript index 75587452..8032836f 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -1,9 +1,35 @@ #!/usr/bin/python import sys, os -Import("test_env") +Import("env") + +tests = [] + +for arg in sys.argv[1:]: + if arg.find("tests") == 0: + tests += [ arg ] + +if len(tests) == 0: + Return() + +env.Append(CCFLAGS = "-DCONFIG_TEST") +env.UsePackage("glib-2.0") + +class UnitTest: + def __init__(self, test, sources): + name = os.path.basename(test) + make = env.Program(name, sources) + run = Command("%s.fake" % name, [], "tests/%s" % test) + Depends(run, make) + Alias("tests/%s" % test, run) + +res = UnitTest("sanity", [ "sanity.cpp", "test.cpp" ]) + +Return("res") + + + res = [] - def all_tests_enabled(dir): for arg in sys.argv[1:]: arg = os.path.normpath(arg) @@ -26,8 +52,6 @@ def get_test_obj(name, dir): 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) @@ -47,14 +71,7 @@ def generic_test(name, dir, objs, extra): 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") +#SConscript("core/Sconscript") Return("res")