From: g0dil Date: Fri, 9 Oct 2009 11:32:17 +0000 (+0000) Subject: More flexible only_tests extension handling and diagnostics X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=60cc2731a8383758e768b552bccf842289ffd784;p=senf.git More flexible only_tests extension handling and diagnostics Automatically enforce .test.cc extension either by adding it or replacing an existing extension. Check for unknown unit test sources in only_tests git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1486 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/site_scons/SparseTestHack.py b/site_scons/SparseTestHack.py index 8ae888d..3ecacaf 100644 --- a/site_scons/SparseTestHack.py +++ b/site_scons/SparseTestHack.py @@ -1,4 +1,4 @@ -import SCons.Node, SCons.Node.FS, SCons.Util +import SCons.Node, SCons.Node.FS, SCons.Util, SCons.Errors ##################################################################### # This IS a hack .. but a very useful one: The hack will remove the @@ -87,10 +87,15 @@ def setup(env): def build(env): env = env.Clone(LIBS = [ '$EXTRA_LIBS' ]) if env.has_key("only_tests"): - only_tests = [ env.Dir(env.GetLaunchDir()).File(test) - for test in env.Split(env['only_tests']) ] + only_tests = {} + dir = env.Dir(env.GetLaunchDir()) + for test in env.Split(env['only_tests']): + test = dir.File(test) + if not test.name.endswith(".test.cc"): + test = test.target_from_source(prefix="", suffix=".test.cc") + only_tests[test] = False else: - only_tests = [] + only_tests = {} for target, tests, kw in env['_UNIT_TEST_LIST']: objects = [] build = False @@ -98,7 +103,8 @@ def build(env): if test.suffix == env['OBJSUFFIX']: objects.append(test) else: - if not only_tests or test in only_tests: + if not only_tests or only_tests.has_key(test): + if only_tests : only_tests[test] = True objects.extend(env.Object(test)) build = True elif test.name == 'main.test.cc': @@ -117,3 +123,8 @@ def build(env): objects = [ ob for ob in objects if not sources.get(ob) ] env.RealBoostUnitTest(target, objects, **kw) + + only_tests = [ k for k,v in only_tests.iteritems() if not v ] + if only_tests: + raise SCons.Errors.StopError("Unknown unit tests (only_tests): %s." + % ", ".join("`%s'" % x for x in only_tests))