summaryrefslogtreecommitdiffstats
path: root/QMTest/TestCommonTests.py
diff options
context:
space:
mode:
authordirkbaechle <devnull@localhost>2012-09-06 23:16:49 (GMT)
committerdirkbaechle <devnull@localhost>2012-09-06 23:16:49 (GMT)
commit299a549ae875c18748f395aca51068e27ac0d489 (patch)
tree3d3613396456a717288d7b5e20f38eb5833c5698 /QMTest/TestCommonTests.py
parent1c8744b6d4ec8812746415d1aae4f13e634809ca (diff)
downloadSCons-299a549ae875c18748f395aca51068e27ac0d489.zip
SCons-299a549ae875c18748f395aca51068e27ac0d489.tar.gz
SCons-299a549ae875c18748f395aca51068e27ac0d489.tar.bz2
- 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
Diffstat (limited to 'QMTest/TestCommonTests.py')
-rw-r--r--QMTest/TestCommonTests.py210
1 files changed, 210 insertions, 0 deletions
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,