From: g0dil Date: Fri, 9 Oct 2009 12:29:53 +0000 (+0000) Subject: Implement test_changes build target X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=38fefda326ca127aa20a234755d9bb5cf0910516;p=senf.git Implement test_changes build target git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1488 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConstruct b/SConstruct index 97ef138..de6f8aa 100644 --- a/SConstruct +++ b/SConstruct @@ -119,6 +119,14 @@ senfutil.parseArguments( BoolVariable('sparse_tests', 'Link tests against object files and not the senf lib', False) ) +if 'test_changes' in COMMAND_LINE_TARGETS and not env.has_key('only_tests'): + if os.popen("svnversion").read().strip() == "exported": + env['only_tests'] = " ".join(os.popen("git ls-files --modified").read().strip().split("\n")) + else: + env['only_tests'] = " ".join(l[7:] + for l in os.popen("svn status").read().rstrip().split("\n") + if l[0] == 'M') + if env.has_key('only_tests') : env['sparse_tests'] = True Export('env') @@ -148,7 +156,7 @@ SConscript("Examples/SConscript") SConscript("HowTos/SConscript") SConscript("doclib/SConscript") if env['sparse_tests']: - SparseTestHack.build(env) + SparseTestHack.build(env, 'test_changes' in COMMAND_LINE_TARGETS) ########################################################################### # Define build targets @@ -164,6 +172,7 @@ env.Install('${INCLUDEINSTALLDIR}', 'boost') env.Alias('install_all', env.FindInstalledFiles()) env.Alias('default', DEFAULT_TARGETS) env.Alias('all_tests', env.FindAllBoostUnitTests()) +env.Alias('test_changes', 'all_tests') env.Alias('all', [ 'default', 'all_tests', 'examples', 'all_docs' ]) #### prepare diff --git a/site_scons/SparseTestHack.py b/site_scons/SparseTestHack.py index 3ecacaf..76e9ee2 100644 --- a/site_scons/SparseTestHack.py +++ b/site_scons/SparseTestHack.py @@ -84,7 +84,7 @@ def setup(env): # This needs to be called after all build targets have been set # up. This is important since the list of object targets needs to be # complete. -def build(env): +def build(env, accept_unknown_tests=False): env = env.Clone(LIBS = [ '$EXTRA_LIBS' ]) if env.has_key("only_tests"): only_tests = {} @@ -124,7 +124,8 @@ def build(env): 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)) + if not accept_unknown_tests: + 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))