From af2b9e2f216459fcdc26f367aaaf528d8122283b Mon Sep 17 00:00:00 2001 From: dirkbaechle Date: Wed, 3 Oct 2012 13:40:03 +0200 Subject: - final changes for bug2872 "Fix tests on Buildbot slaves", mainly switched all RPM tests to using the new rpmutils module --- src/engine/SCons/Tool/xgettext.py | 5 ++++- test/packaging/option--package-type.py | 7 ++++--- test/packaging/rpm/cleanup.py | 5 +++-- test/packaging/rpm/internationalization.py | 17 ++++++++--------- test/runtest/python.py | 4 +++- test/sconsign/script/Configure.py | 6 +++++- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index 17e055f..64436b8 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -271,7 +271,10 @@ def generate(env,**kw): import SCons.Util from SCons.Tool.GettextCommon import RPaths, _detect_xgettext - env['XGETTEXT'] = _detect_xgettext(env) + try: + env['XGETTEXT'] = _detect_xgettext(env) + except: + env['XGETTEXT'] = 'xgettext' # NOTE: sources="$SOURCES" would work as well. However, we use following # construction to convert absolute paths provided by scons onto paths # relative to current working dir. Note, that scons expands $SOURCE(S) to diff --git a/test/packaging/option--package-type.py b/test/packaging/option--package-type.py index 2a898ff..c8f22ca 100644 --- a/test/packaging/option--package-type.py +++ b/test/packaging/option--package-type.py @@ -29,6 +29,7 @@ Test the --package-type option. """ import TestSCons +import SCons.Tool.rpmutils _python_ = TestSCons._python_ @@ -67,12 +68,12 @@ env.Package( NAME = 'foo', """ % locals()) src_rpm = 'foo-1.2.3-0.src.rpm' -machine_rpm = 'foo-1.2.3-0.*.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % SCons.Tool.rpmutils.defaultMachine() test.run(arguments='package PACKAGETYPE=rpm', stderr = None) test.must_exist( src_rpm ) -test.must_exist_one_of( [machine_rpm] ) +test.must_exist( machine_rpm ) test.must_not_exist( 'bin/main.c' ) test.must_not_exist( '/bin/main.c' ) @@ -80,7 +81,7 @@ test.run(arguments='-c package PACKAGETYPE=rpm', stderr = None) test.run(arguments='package --package-type=rpm', stderr = None) test.must_exist( src_rpm ) -test.must_exist_one_of( [machine_rpm] ) +test.must_exist( machine_rpm ) test.must_not_exist( 'bin/main.c' ) test.must_not_exist( '/bin/main.c' ) diff --git a/test/packaging/rpm/cleanup.py b/test/packaging/rpm/cleanup.py index 91feba1..b77dfd1 100644 --- a/test/packaging/rpm/cleanup.py +++ b/test/packaging/rpm/cleanup.py @@ -29,6 +29,7 @@ Assert that files created by the RPM packager will be removed by 'scons -c'. """ import TestSCons +import SCons.Tool.rpmutils _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -88,9 +89,9 @@ test.up_to_date( arguments='.' ) test.run( arguments='-c .' ) src_rpm = 'foo-1.2.3-0.src.rpm' -machine_rpm = 'foo-1.2.3-0.*.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % SCons.Tool.rpmutils.defaultMachine() -test.must_not_exist_any_of( [machine_rpm] ) +test.must_not_exist( machine_rpm ) test.must_not_exist( src_rpm ) test.must_not_exist( 'foo-1.2.3.tar.gz' ) test.must_not_exist( 'foo-1.2.3.spec' ) diff --git a/test/packaging/rpm/internationalization.py b/test/packaging/rpm/internationalization.py index 4b75de4..2ef0dfd 100644 --- a/test/packaging/rpm/internationalization.py +++ b/test/packaging/rpm/internationalization.py @@ -32,7 +32,7 @@ These are x-rpm-Group, description, summary and the lang_xx file tag. """ import os -import glob +import SCons.Tool.rpmutils import TestSCons @@ -95,30 +95,29 @@ env.Alias ( 'install', prog ) test.run(arguments='', stderr = None) src_rpm = 'foo-1.2.3-0.src.rpm' -machine_rpm = 'foo-1.2.3-0.*.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % SCons.Tool.rpmutils.defaultMachine() test.must_exist( src_rpm ) -test.must_exist_one_of( [machine_rpm] ) +test.must_exist( machine_rpm ) test.must_not_exist( 'bin/main' ) -machine_rpm_path = glob.glob(machine_rpm)[0].lstrip('./') cmd = 'rpm -qp --queryformat \'%%{GROUP}-%%{SUMMARY}-%%{DESCRIPTION}\' %s' os.environ['LANGUAGE'] = 'de' -out = os.popen( cmd % test.workpath(machine_rpm_path) ).read() +out = os.popen( cmd % test.workpath(machine_rpm) ).read() test.fail_test( out != 'Applikation/büro-hallo-das sollte wirklich lang sein' ) os.environ['LANGUAGE'] = 'fr' -out = os.popen( cmd % test.workpath(machine_rpm_path) ).read() +out = os.popen( cmd % test.workpath(machine_rpm) ).read() test.fail_test( out != 'Application/bureau-bonjour-ceci devrait être vraiment long' ) os.environ['LANGUAGE'] = 'en' -out = os.popen( cmd % test.workpath(machine_rpm_path) ).read() +out = os.popen( cmd % test.workpath(machine_rpm) ).read() test.fail_test( out != 'Application/office-hello-this should be really long' ) os.environ['LC_ALL'] = 'ae' -out = os.popen( cmd % test.workpath(machine_rpm_path) ).read() +out = os.popen( cmd % test.workpath(machine_rpm) ).read() test.fail_test( out != 'Application/office-hello-this should be really long' ) # @@ -177,7 +176,7 @@ env.Alias ( 'install', [ prog, man_pages ] ) test.run(arguments='--install-sandbox=blubb install', stderr = None) test.must_exist( src_rpm ) -test.must_exist_one_of( [machine_rpm] ) +test.must_exist( machine_rpm ) test.pass_test() diff --git a/test/runtest/python.py b/test/runtest/python.py index d406be4..bcbc062 100644 --- a/test/runtest/python.py +++ b/test/runtest/python.py @@ -43,7 +43,9 @@ test_pass_py = os.path.join('test', 'pass.py') head, python = os.path.split(TestRuntest.python) head, dir = os.path.split(head) -mypython = os.path.join(head, dir, os.path.pardir, dir, python) +# We have to normalize the python path here, because some installations don't like +# getting called with "/bin/../bin/python" as first argument, e.g. Fedora 17 Desktop. +mypython = os.path.normpath(os.path.join(head, dir, os.path.pardir, dir, python)) def escape(s): return s.replace('\\', '\\\\') diff --git a/test/sconsign/script/Configure.py b/test/sconsign/script/Configure.py index 865b607..3b43def 100644 --- a/test/sconsign/script/Configure.py +++ b/test/sconsign/script/Configure.py @@ -40,7 +40,11 @@ _obj = TestSCons._obj test = TestSConsign.TestSConsign(match = TestSConsign.match_re, diff = TestSConsign.diff_re) -CC = test.detect('CC', norm=1) +# Note: Here we pass the full search PATH of our current system to +# the detect() method. This way we try to ensure that we find the same +# compiler executable as the SConstruct below, which uses +# os.environ['PATH'] too. +CC = test.detect('CC', ENV={'PATH' : os.environ.get('PATH','')}, norm=1) CC_dir, CC_file = os.path.split(CC) CC = re.escape(CC) -- cgit v0.12 From 46043901f7a93385e5bb2d3243073bd6c5634ca8 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sat, 6 Oct 2012 17:54:14 -0400 Subject: Fix nested LIBPATH expansion by flattening sequences in subst_path. Patch from Alexey Klimkin; fixes issue #2660. --- src/CHANGES.txt | 3 +++ src/engine/SCons/EnvironmentTests.py | 15 +++++++++++++++ src/engine/SCons/PathList.py | 10 ++++++---- src/engine/SCons/PathListTests.py | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c903ece..ca6c5df 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,9 @@ RELEASE 2.X.X - + From Alexey Klimkin: + - Fix nested LIBPATH expansion by flattening sequences in subst_path. + From eyan on Bitbucket: - Print target name with command execution time with --debug=time diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 9237c8a..45cf876 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1440,6 +1440,21 @@ def exists(env): x = s("${_concat(PRE, LIST, SUF, __env__)}") assert x == 'preasuf prebsuf', x + def test_concat_nested(self): + "Test _concat() on a nested substitution strings." + e = self.TestEnvironment(PRE='pre', SUF='suf', + L1=['a', 'b'], + L2=['c', 'd'], + L3=['$L2']) + x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)') + assert x == 'preasuf prebsuf', x + e.AppendUnique(L1 = ['$L2']) + x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)') + assert x == 'preasuf prebsuf precsuf predsuf', x + e.AppendUnique(L1 = ['$L3']) + x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)') + assert x == 'preasuf prebsuf precsuf predsuf precsuf predsuf', x + def test_gvars(self): """Test the Environment gvars() method""" env = self.TestEnvironment(XXX = 'x', YYY = 'y', ZZZ = 'z') diff --git a/src/engine/SCons/PathList.py b/src/engine/SCons/PathList.py index 870c195..f3de57c 100644 --- a/src/engine/SCons/PathList.py +++ b/src/engine/SCons/PathList.py @@ -131,12 +131,14 @@ class _PathList(object): value = env.subst(value, target=target, source=source, conv=node_conv) if SCons.Util.is_Sequence(value): - result.extend(value) - continue - + result.extend(SCons.Util.flatten(value)) + elif value: + result.append(value) elif type == TYPE_OBJECT: value = node_conv(value) - if value: + if value: + result.append(value) + elif value: result.append(value) return tuple(result) diff --git a/src/engine/SCons/PathListTests.py b/src/engine/SCons/PathListTests.py index 212c761..e83fc50 100644 --- a/src/engine/SCons/PathListTests.py +++ b/src/engine/SCons/PathListTests.py @@ -48,6 +48,8 @@ class subst_pathTestCase(unittest.TestCase): return s self.env = FakeEnvironment(AAA = 'aaa', NULL = '') + from SCons.Environment import Environment + self.env = Environment(AAA = 'aaa', NULL = '') def test_node(self): """Test the subst_path() method on a Node @@ -120,6 +122,40 @@ class subst_pathTestCase(unittest.TestCase): assert result == ('aaa',), result + def test_list_of_lists(self): + """Test the subst_path() method on substitution of nested lists. + """ + pl = SCons.PathList.PathList((['$AAA', '$AAA'], '$NULL')) + result = pl.subst_path(self.env, 'y', 'z') + assert result == ('aaa', 'aaa'), result + + def test_subst_nested(self): + """Test the subst_path() method on nested substitution of strings. + """ + self.env.Append(L1 = ['a', 'b'], + L2 = ['c', 'd'], + L3 = ['$L2']) + pl = SCons.PathList.PathList(['$L1']) + result = pl.subst_path(self.env, 'y', 'z') + assert result == ('a', 'b'), result + self.env.Append(L1 = ['$L2']) + pl = SCons.PathList.PathList(['$L1']) + result = pl.subst_path(self.env, 'y', 'z') + assert result == ('a', 'b', 'c', 'd'), result + self.env.Append(L1 = ['$L3']) + pl = SCons.PathList.PathList(['$L1']) + result = pl.subst_path(self.env, 'y', 'z') + assert result == ('a', 'b', 'c', 'd', 'c', 'd'), result + + def test_another_env(self): + """Test the subst_path does lazy evaluation. + """ + pl = SCons.PathList.PathList(('$AAA', '$NULL')) + result = pl.subst_path(self.env, 'y', 'z') + assert result == ('aaa',), result + e = self.env.Clone(AAA = 'bbb') + result = pl.subst_path(e, 'y', 'z') + assert result == ('bbb',), result class PathListCacheTestCase(unittest.TestCase): -- cgit v0.12