From 299a549ae875c18748f395aca51068e27ac0d489 Mon Sep 17 00:00:00 2001 From: dirkbaechle Date: Fri, 7 Sep 2012 01:16:49 +0200 Subject: - added two new functions must_exist_one_of/must_not_exist_any_of to TestCmd, supporting wildcards - rewrote several test/packaging tests, using the new matching functions instead of relying on the os.uname() machine value for determining the resulting RPM filename - renamed glob modules in test/scons-time to avoid name clashes - minor fix: added Java 1.7 as supported version to Tool/JavaCommon.py --- QMTest/TestCmdTests.py | 8 +- QMTest/TestCommon.py | 48 +++++++ QMTest/TestCommonTests.py | 210 +++++++++++++++++++++++++++++ src/engine/SCons/Tool/JavaCommon.py | 2 +- test/packaging/option--package-type.py | 15 +-- test/packaging/rpm/cleanup.py | 13 +- test/packaging/rpm/internationalization.py | 24 ++-- test/packaging/rpm/multipackage.py | 19 +-- test/packaging/rpm/package.py | 15 +-- test/packaging/rpm/tagging.py | 15 +-- test/scons-time/func/funcglob.py | 63 +++++++++ test/scons-time/func/glob.py | 63 --------- test/scons-time/mem/glob.py | 58 -------- test/scons-time/mem/memglob.py | 58 ++++++++ test/scons-time/obj/glob.py | 58 -------- test/scons-time/obj/objglob.py | 58 ++++++++ test/scons-time/time/glob.py | 58 -------- test/scons-time/time/timeglob.py | 58 ++++++++ 18 files changed, 528 insertions(+), 315 deletions(-) create mode 100644 test/scons-time/func/funcglob.py delete mode 100644 test/scons-time/func/glob.py delete mode 100644 test/scons-time/mem/glob.py create mode 100644 test/scons-time/mem/memglob.py delete mode 100644 test/scons-time/obj/glob.py create mode 100644 test/scons-time/obj/objglob.py delete mode 100644 test/scons-time/time/glob.py create mode 100644 test/scons-time/time/timeglob.py diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index 357413f..1fe328c 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -551,8 +551,8 @@ result = TestCmd.TestCmd.context_diff(['a\\n', 'b\\n', 'c\\n', 'e\\n', 'f1\\n'], ['a\\n', 'c\\n', 'd\\n', 'e\\n', 'f2\\n']) result = list(result) expect = [ - '*** \\n', - '--- \\n', + '*** \\n', + '--- \\n', '***************\\n', '*** 1,5 ****\\n', ' a\\n', @@ -580,8 +580,8 @@ result = TestCmd.TestCmd.unified_diff(['a\\n', 'b\\n', 'c\\n', 'e\\n', 'f1\\n'], ['a\\n', 'c\\n', 'd\\n', 'e\\n', 'f2\\n']) result = list(result) expect = [ - '--- \\n', - '+++ \\n', + '--- \\n', + '+++ \\n', '@@ -1,5 +1,5 @@\\n', ' a\\n', '-b\\n', diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index c677226..90aaed2 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -99,6 +99,7 @@ import copy import os import stat import sys +import glob try: from collections import UserList @@ -204,6 +205,14 @@ else: def is_List(e): return isinstance(e, (list, UserList)) +def is_Tuple(e): + return isinstance(e, tuple) + +def is_Sequence(e): + return (not hasattr(e, "strip") and + hasattr(e, "__getitem__") or + hasattr(e, "__iter__")) + def is_writable(f): mode = os.stat(f)[stat.ST_MODE] return mode & stat.S_IWUSR @@ -422,6 +431,26 @@ class TestCommon(TestCmd): print "Missing files: `%s'" % "', `".join(missing) self.fail_test(missing) + def must_exist_one_of(self, files): + """Ensures that at least one of the specified file(s) exists. + The filenames can be given as a list, where each entry may be + a single path string, or a tuple of folder names and the final + filename that get concatenated. + Supports wildcard names like 'foo-1.2.3-*.rpm'. + Exits FAILED if none of the files exists. + """ + missing = [] + for x in files: + if is_List(x) or is_Tuple(x): + xpath = os.path.join(*x) + else: + xpath = is_Sequence(x) and os.path.join(x) or x + if glob.glob(xpath): + return + missing.append(xpath) + print "Missing one of: `%s'" % "', `".join(missing) + self.fail_test(missing) + def must_match(self, file, expect, mode = 'rb'): """Matches the contents of the specified file (first argument) against the expected contents (second argument). The expected @@ -498,6 +527,25 @@ class TestCommon(TestCmd): print "Unexpected files exist: `%s'" % "', `".join(existing) self.fail_test(existing) + def must_not_exist_any_of(self, files): + """Ensures that none of the specified file(s) exists. + The filenames can be given as a list, where each entry may be + a single path string, or a tuple of folder names and the final + filename that get concatenated. + Supports wildcard names like 'foo-1.2.3-*.rpm'. + Exits FAILED if any of the files exists. + """ + existing = [] + for x in files: + if is_List(x) or is_Tuple(x): + xpath = os.path.join(*x) + else: + xpath = is_Sequence(x) and os.path.join(x) or x + if glob.glob(xpath): + existing.append(xpath) + if existing: + print "Unexpected files exist: `%s'" % "', `".join(existing) + self.fail_test(existing) def must_not_be_writable(self, *files): """Ensures that the specified file(s) exist and are not writable. diff --git a/QMTest/TestCommonTests.py b/QMTest/TestCommonTests.py index a19fc83..30b7d6a 100644 --- a/QMTest/TestCommonTests.py +++ b/QMTest/TestCommonTests.py @@ -991,7 +991,111 @@ class must_exist_TestCase(TestCommonTestCase): stderr = run_env.stderr() assert stderr == "PASSED\n", stderr +class must_exist_one_of_TestCase(TestCommonTestCase): + def test_success(self): + """Test must_exist_one_of(): success""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file1', "file1\\n") + tc.must_exist_one_of(['file1']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_failure(self): + """Test must_exist_one_of(): failure""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.must_exist_one_of(['file1']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "Missing one of: `file1'\n", stdout + stderr = run_env.stderr() + assert stderr.find("FAILED") != -1, stderr + + def test_files_specified_as_list(self): + """Test must_exist_one_of(): files specified as list""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file1', "file1\\n") + tc.must_exist_one_of(['file2', 'file1']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_files_specified_with_wildcards(self): + """Test must_exist_one_of(): files specified with wildcards""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file7', "file7\\n") + tc.must_exist_one_of(['file?']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_file_given_as_list(self): + """Test must_exist_one_of(): file given as list""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.subdir('sub') + tc.write(['sub', 'file1'], "sub/file1\\n") + tc.must_exist_one_of(['file2', + ['sub', 'file1']]) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + def test_file_given_as_sequence(self): + """Test must_exist_one_of(): file given as sequence""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.subdir('sub') + tc.write(['sub', 'file1'], "sub/file1\\n") + tc.must_exist_one_of(['file2', + ('sub', 'file1')]) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr class must_match_TestCase(TestCommonTestCase): def test_success(self): @@ -1532,6 +1636,110 @@ class must_not_exist_TestCase(TestCommonTestCase): stderr = run_env.stderr() assert stderr.find("FAILED") != -1, stderr +class must_not_exist_any_of_TestCase(TestCommonTestCase): + def test_success(self): + """Test must_not_exist_any_of(): success""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.must_not_exist_any_of(['file1']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_failure(self): + """Test must_not_exist_any_of(): failure""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file1', "file1\\n") + tc.must_not_exist_any_of(['file1']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "Unexpected files exist: `file1'\n", stdout + stderr = run_env.stderr() + assert stderr.find("FAILED") != -1, stderr + + def test_files_specified_as_list(self): + """Test must_not_exist_any_of(): files specified as list""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.must_not_exist_any_of(['file2', 'file1']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_files_specified_with_wildcards(self): + """Test must_not_exist_any_of(): files specified with wildcards""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file7', "file7\\n") + tc.must_not_exist_any_of(['files?']) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_file_given_as_list(self): + """Test must_not_exist_any_of(): file given as list""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.subdir('sub') + tc.write(['sub', 'file1'], "sub/file1\\n") + tc.must_not_exist_any_of(['file2', + ['sub', 'files*']]) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_file_given_as_sequence(self): + """Test must_not_exist_any_of(): file given as sequence""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.subdir('sub') + tc.write(['sub', 'file1'], "sub/file1\\n") + tc.must_not_exist_any_of(['file2', + ('sub', 'files?')]) + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr class run_TestCase(TestCommonTestCase): def test_argument_handling(self): @@ -2102,12 +2310,14 @@ if __name__ == "__main__": must_contain_exactly_lines_TestCase, must_contain_lines_TestCase, must_exist_TestCase, + must_exist_one_of_TestCase, must_match_TestCase, must_not_be_writable_TestCase, must_not_contain_TestCase, must_not_contain_any_line_TestCase, must_not_contain_lines_TestCase, must_not_exist_TestCase, + must_not_exist_any_of_TestCase, run_TestCase, start_TestCase, skip_test_TestCase, diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index bb9caab..156ef97 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -171,7 +171,7 @@ if java_parsing: if self.version in ('1.1', '1.2', '1.3', '1.4'): clazz = self.listClasses[0] self.listOutputs.append('%s$%d' % (clazz, self.nextAnon)) - elif self.version in ('1.5', '1.6', '5', '6'): + elif self.version in ('1.5', '1.6', '1.7', '5', '6'): self.stackAnonClassBrackets.append(self.brackets) className = [] className.extend(self.listClasses) diff --git a/test/packaging/option--package-type.py b/test/packaging/option--package-type.py index 9bfa565..2a898ff 100644 --- a/test/packaging/option--package-type.py +++ b/test/packaging/option--package-type.py @@ -30,15 +30,6 @@ Test the --package-type option. import TestSCons -machine = TestSCons.machine -try: - # Try to get the actual machine type (like i586), since - # TestSCons maps all ix86 types to a i386 machine internally. - import os - machine = os.uname()[4] -except AttributeError: - pass - _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -76,12 +67,12 @@ env.Package( NAME = 'foo', """ % locals()) src_rpm = 'foo-1.2.3-0.src.rpm' -machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine +machine_rpm = 'foo-1.2.3-0.*.rpm' test.run(arguments='package PACKAGETYPE=rpm', stderr = None) test.must_exist( src_rpm ) -test.must_exist( machine_rpm ) +test.must_exist_one_of( [machine_rpm] ) test.must_not_exist( 'bin/main.c' ) test.must_not_exist( '/bin/main.c' ) @@ -89,7 +80,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( machine_rpm ) +test.must_exist_one_of( [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 9d79219..91feba1 100644 --- a/test/packaging/rpm/cleanup.py +++ b/test/packaging/rpm/cleanup.py @@ -30,16 +30,7 @@ Assert that files created by the RPM packager will be removed by 'scons -c'. import TestSCons -machine = TestSCons.machine -try: - # Try to get the actual machine type (like i586), since - # TestSCons maps all ix86 types to a i386 machine internally. - import os - machine = os.uname()[4] -except AttributeError: - pass _python_ = TestSCons._python_ - test = TestSCons.TestSCons() scons = test.program @@ -97,9 +88,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.%s.rpm' % machine +machine_rpm = 'foo-1.2.3-0.*.rpm' -test.must_not_exist( machine_rpm ) +test.must_not_exist_any_of( [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 a9bd926..4b75de4 100644 --- a/test/packaging/rpm/internationalization.py +++ b/test/packaging/rpm/internationalization.py @@ -32,17 +32,10 @@ These are x-rpm-Group, description, summary and the lang_xx file tag. """ import os +import glob import TestSCons -machine = TestSCons.machine -try: - # Try to get the actual machine type (like i586), since - # TestSCons maps all ix86 types to a i386 machine internally. - import os - machine = os.uname()[4] -except AttributeError: - pass _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -102,29 +95,30 @@ 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.%s.rpm' % machine +machine_rpm = 'foo-1.2.3-0.*.rpm' test.must_exist( src_rpm ) -test.must_exist( machine_rpm ) +test.must_exist_one_of( [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) ).read() +out = os.popen( cmd % test.workpath(machine_rpm_path) ).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) ).read() +out = os.popen( cmd % test.workpath(machine_rpm_path) ).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) ).read() +out = os.popen( cmd % test.workpath(machine_rpm_path) ).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) ).read() +out = os.popen( cmd % test.workpath(machine_rpm_path) ).read() test.fail_test( out != 'Application/office-hello-this should be really long' ) # @@ -183,7 +177,7 @@ env.Alias ( 'install', [ prog, man_pages ] ) test.run(arguments='--install-sandbox=blubb install', stderr = None) test.must_exist( src_rpm ) -test.must_exist( machine_rpm ) +test.must_exist_one_of( [machine_rpm] ) test.pass_test() diff --git a/test/packaging/rpm/multipackage.py b/test/packaging/rpm/multipackage.py index 4f10a8a..4807a20 100644 --- a/test/packaging/rpm/multipackage.py +++ b/test/packaging/rpm/multipackage.py @@ -30,16 +30,9 @@ from one SCons environment. """ import os +import glob import TestSCons -machine = TestSCons.machine -try: - # Try to get the actual machine type (like i586), since - # TestSCons maps all ix86 types to a i386 machine internally. - import os - machine = os.uname()[4] -except AttributeError: - pass _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -105,18 +98,18 @@ 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.%s.rpm' % machine +machine_rpm = 'foo-1.2.3-0.*.rpm' src_rpm2 = 'foo2-1.2.3-0.src.rpm' -machine_rpm2 = 'foo2-1.2.3-0.%s.rpm' % machine +machine_rpm2 = 'foo2-1.2.3-0.*.rpm' -test.must_exist( machine_rpm ) +test.must_exist_one_of( [machine_rpm] ) test.must_exist( src_rpm ) -test.must_exist( machine_rpm2 ) +test.must_exist_one_of( [machine_rpm2] ) test.must_exist( src_rpm2 ) test.must_not_exist( 'bin/main' ) -test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') +test.fail_test( not os.popen('rpm -qpl %s' % glob.glob(machine_rpm)[0].lstrip('./')).read()=='/bin/main\n') test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') test.pass_test() diff --git a/test/packaging/rpm/package.py b/test/packaging/rpm/package.py index 3a55e33..b1abaab 100644 --- a/test/packaging/rpm/package.py +++ b/test/packaging/rpm/package.py @@ -29,16 +29,9 @@ Test the ability to create a really simple rpm package. """ import os +import glob import TestSCons -machine = TestSCons.machine -try: - # Try to get the actual machine type (like i586), since - # TestSCons maps all ix86 types to a i386 machine internally. - import os - machine = os.uname()[4] -except AttributeError: - pass _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -90,12 +83,12 @@ 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.%s.rpm' % machine +machine_rpm = 'foo-1.2.3-0.*.rpm' -test.must_exist( machine_rpm ) +test.must_exist_one_of( [machine_rpm] ) test.must_exist( src_rpm ) test.must_not_exist( 'bin/main' ) -test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') +test.fail_test( not os.popen('rpm -qpl %s' % glob.glob(machine_rpm)[0].lstrip('./')).read()=='/bin/main\n') test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') test.pass_test() diff --git a/test/packaging/rpm/tagging.py b/test/packaging/rpm/tagging.py index 4e43d93..4d6c76e 100644 --- a/test/packaging/rpm/tagging.py +++ b/test/packaging/rpm/tagging.py @@ -29,17 +29,10 @@ Test the ability to add file tags """ import os +import glob import TestSCons -machine = TestSCons.machine -try: - # Try to get the actual machine type (like i586), since - # TestSCons maps all ix86 types to a i386 machine internally. - import os - machine = os.uname()[4] -except AttributeError: - pass _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -95,11 +88,11 @@ env.Package( NAME = 'foo', test.run(arguments='', stderr = None) src_rpm = 'foo-1.2.3-0.src.rpm' -machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine +machine_rpm = 'foo-1.2.3-0.*.rpm' -test.must_exist( machine_rpm ) +test.must_exist_one_of( [machine_rpm] ) test.must_exist( src_rpm ) -test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') +test.fail_test( not os.popen('rpm -qpl %s' % glob.glob(machine_rpm)[0].lstrip('./')).read()=='/bin/main\n') test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') expect = '(0755, root, users) /bin/main' diff --git a/test/scons-time/func/funcglob.py b/test/scons-time/func/funcglob.py new file mode 100644 index 0000000..6240404 --- /dev/null +++ b/test/scons-time/func/funcglob.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that the func subcommands globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +input = """\ +def _main(): + pass +""" + +expect = [] +for i in range(9): + test.subdir(str(i)) + test.profile_data('foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) + expect.append((r'\d.\d\d\d %s/prof\.py:1\(_main\)' + '\n') % i) + +expect = ''.join(expect) + +test.run(arguments = 'func foo-*.prof', stdout = expect) + +test.run(arguments = 'func foo-?.prof', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/glob.py b/test/scons-time/func/glob.py deleted file mode 100644 index 6240404..0000000 --- a/test/scons-time/func/glob.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Verify that the func subcommands globs for files. -""" - -import TestSCons_time - -test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) - -try: - import pstats -except ImportError: - test.skip_test('No pstats module, skipping test.\n') - -input = """\ -def _main(): - pass -""" - -expect = [] -for i in range(9): - test.subdir(str(i)) - test.profile_data('foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) - expect.append((r'\d.\d\d\d %s/prof\.py:1\(_main\)' + '\n') % i) - -expect = ''.join(expect) - -test.run(arguments = 'func foo-*.prof', stdout = expect) - -test.run(arguments = 'func foo-?.prof', stdout = expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/glob.py b/test/scons-time/mem/glob.py deleted file mode 100644 index 820021e..0000000 --- a/test/scons-time/mem/glob.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Verify that the mem subommand globs for files. -""" - -import TestSCons_time - -test = TestSCons_time.TestSCons_time() - -lines = [ - ' pre-read post-read pre-build post-build\n' -] - -line_fmt = ' 1000 2000 3000 4000 %s\n' - -for i in range(9): - logfile_name = 'foo-%s.log' % i - test.fake_logfile(logfile_name) - lines.append(line_fmt % logfile_name) - -expect = ''.join(lines) - -test.run(arguments = 'mem foo-*.log', stdout = expect) - -test.run(arguments = 'mem foo-?.log', stdout = expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/memglob.py b/test/scons-time/mem/memglob.py new file mode 100644 index 0000000..820021e --- /dev/null +++ b/test/scons-time/mem/memglob.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that the mem subommand globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +lines = [ + ' pre-read post-read pre-build post-build\n' +] + +line_fmt = ' 1000 2000 3000 4000 %s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = ''.join(lines) + +test.run(arguments = 'mem foo-*.log', stdout = expect) + +test.run(arguments = 'mem foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/glob.py b/test/scons-time/obj/glob.py deleted file mode 100644 index 2105355..0000000 --- a/test/scons-time/obj/glob.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Verify that the obj subcommand globs for files. -""" - -import TestSCons_time - -test = TestSCons_time.TestSCons_time() - -lines = [ - ' pre-read post-read pre-build post-build\n' -] - -line_fmt = ' 601%(i)s 602%(i)s 603%(i)s 604%(i)s %(logfile_name)s\n' - -for i in range(9): - logfile_name = 'foo-%s.log' % i - test.fake_logfile(logfile_name, i) - lines.append(line_fmt % locals()) - -expect = ''.join(lines) - -test.run(arguments = 'obj Builder.BuilderBase foo-*.log', stdout = expect) - -test.run(arguments = 'obj Builder.BuilderBase foo-?.log', stdout = expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/objglob.py b/test/scons-time/obj/objglob.py new file mode 100644 index 0000000..2105355 --- /dev/null +++ b/test/scons-time/obj/objglob.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that the obj subcommand globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +lines = [ + ' pre-read post-read pre-build post-build\n' +] + +line_fmt = ' 601%(i)s 602%(i)s 603%(i)s 604%(i)s %(logfile_name)s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name, i) + lines.append(line_fmt % locals()) + +expect = ''.join(lines) + +test.run(arguments = 'obj Builder.BuilderBase foo-*.log', stdout = expect) + +test.run(arguments = 'obj Builder.BuilderBase foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/glob.py b/test/scons-time/time/glob.py deleted file mode 100644 index 1a76d9f..0000000 --- a/test/scons-time/time/glob.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Verify that the time subcommand globs for files. -""" - -import TestSCons_time - -test = TestSCons_time.TestSCons_time() - -lines = [ - ' Total SConscripts SCons commands\n' -] - -line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' - -for i in range(9): - logfile_name = 'foo-%s.log' % i - test.fake_logfile(logfile_name) - lines.append(line_fmt % logfile_name) - -expect = ''.join(lines) - -test.run(arguments = 'time foo-*.log', stdout = expect) - -test.run(arguments = 'time foo-?.log', stdout = expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/timeglob.py b/test/scons-time/time/timeglob.py new file mode 100644 index 0000000..1a76d9f --- /dev/null +++ b/test/scons-time/time/timeglob.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that the time subcommand globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +lines = [ + ' Total SConscripts SCons commands\n' +] + +line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = ''.join(lines) + +test.run(arguments = 'time foo-*.log', stdout = expect) + +test.run(arguments = 'time foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12