diff options
author | Steven Knight <knight@baldmt.com> | 2009-12-16 07:07:13 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2009-12-16 07:07:13 (GMT) |
commit | 2af84ec5c72b588ef67f8988d36066f2859c09a1 (patch) | |
tree | 76a5d74c1ecb5a1a17d53d89712d0264b1bfa5de /test/runtest | |
parent | 3f0d3576e54c5fdc1cb3822365a856736a96790e (diff) | |
download | SCons-2af84ec5c72b588ef67f8988d36066f2859c09a1.zip SCons-2af84ec5c72b588ef67f8988d36066f2859c09a1.tar.gz SCons-2af84ec5c72b588ef67f8988d36066f2859c09a1.tar.bz2 |
Fix the tests of runtest.py now that QMTest is no longer being used
by default. Fix use of subprocess in Python 2.4+ and exit statuses
of popen'ed scripts in earlier versions of Python. Support the ability
to execute a directory's tests by naming the directory as a command-
line argument.
Diffstat (limited to 'test/runtest')
-rw-r--r-- | test/runtest/aegis/batch-output.py | 8 | ||||
-rw-r--r-- | test/runtest/baseline/combined.py | 53 | ||||
-rw-r--r-- | test/runtest/baseline/fail.py | 31 | ||||
-rw-r--r-- | test/runtest/baseline/no_result.py | 29 | ||||
-rw-r--r-- | test/runtest/baseline/pass.py | 26 | ||||
-rw-r--r-- | test/runtest/fallback.py | 2 | ||||
-rw-r--r-- | test/runtest/print_time.py | 69 | ||||
-rw-r--r-- | test/runtest/python.py | 28 | ||||
-rw-r--r-- | test/runtest/simple/combined.py | 55 | ||||
-rw-r--r-- | test/runtest/simple/fail.py | 33 | ||||
-rw-r--r-- | test/runtest/simple/no_result.py | 31 | ||||
-rw-r--r-- | test/runtest/simple/pass.py | 26 | ||||
-rw-r--r-- | test/runtest/src.py | 33 | ||||
-rw-r--r-- | test/runtest/testlistfile.py | 28 | ||||
-rw-r--r-- | test/runtest/xml/output.py | 168 |
15 files changed, 218 insertions, 402 deletions
diff --git a/test/runtest/aegis/batch-output.py b/test/runtest/aegis/batch-output.py index bb2aa1e..e2f00ee 100644 --- a/test/runtest/aegis/batch-output.py +++ b/test/runtest/aegis/batch-output.py @@ -40,7 +40,13 @@ test.write_no_result_test(['test', 'no_result.py']) test.write_passing_test(['test', 'pass.py']) -test.run(arguments = '-o aegis.out --aegis test', status=1) +expect_stderr = """\ +FAILING TEST STDERR +NO RESULT TEST STDERR +PASSING TEST STDERR +""" + +test.run(arguments = '-o aegis.out --aegis test', stderr=expect_stderr) expect = """\ test_result = [ diff --git a/test/runtest/baseline/combined.py b/test/runtest/baseline/combined.py index bd47908..02f3f53 100644 --- a/test/runtest/baseline/combined.py +++ b/test/runtest/baseline/combined.py @@ -34,6 +34,7 @@ import os.path import TestRuntest +python = TestRuntest.python test_fail_py = os.path.join('test', 'fail.py') test_no_result_py = os.path.join('test', 'no_result.py') test_pass_py = os.path.join('test', 'pass.py') @@ -48,41 +49,31 @@ test.write_no_result_test(['test', 'no_result.py']) test.write_passing_test(['test', 'pass.py']) -# NOTE: The "test/fail.py : FAIL" and "test/pass.py : PASS" lines both -# have spaces at the end. +expect_stdout = """\ +%(python)s -tt test/fail.py +FAILING TEST STDOUT +%(python)s -tt test/no_result.py +NO RESULT TEST STDOUT +%(python)s -tt test/pass.py +PASSING TEST STDOUT -expect = r"""qmtest run --output baseline.qmr --format none --result-stream="scons_tdb.AegisBaselineStream" test ---- TEST RESULTS ------------------------------------------------------------- +Failed the following test: +\ttest/fail.py - %(test_fail_py)s : FAIL - - FAILING TEST STDOUT - - FAILING TEST STDERR - - %(test_no_result_py)s : NO_RESULT - - NO RESULT TEST STDOUT - - NO RESULT TEST STDERR - - %(test_pass_py)s : PASS - ---- TESTS WITH UNEXPECTED OUTCOMES ------------------------------------------- - - %(test_no_result_py)s : NO_RESULT - - %(test_pass_py)s : PASS - - ---- STATISTICS --------------------------------------------------------------- - - 1 ( 33%%) tests as expected - 1 ( 33%%) tests unexpected PASS - 1 ( 33%%) tests unexpected NO_RESULT +NO RESULT from the following test: +\ttest/no_result.py """ % locals() -test.run(arguments = '-b . test', status = 1, stdout = expect) +expect_stderr = """\ +FAILING TEST STDERR +NO RESULT TEST STDERR +PASSING TEST STDERR +""" + +test.run(arguments='-b . test', + status=1, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/baseline/fail.py b/test/runtest/baseline/fail.py index bd52a18..fb7265e 100644 --- a/test/runtest/baseline/fail.py +++ b/test/runtest/baseline/fail.py @@ -30,34 +30,27 @@ Test how we handle a failing test specified on the command line. import TestRuntest +python = TestRuntest.python + test = TestRuntest.TestRuntest() test.subdir('test') test.write_failing_test(['test', 'fail.py']) -# NOTE: The "test/fail.py : FAIL" line has spaces at the end. - -expect = r"""qmtest run --output baseline.qmr --format none --result-stream="scons_tdb.AegisBaselineStream" test/fail.py ---- TEST RESULTS ------------------------------------------------------------- - - test/fail.py : FAIL - - FAILING TEST STDOUT - - FAILING TEST STDERR - ---- TESTS WITH UNEXPECTED OUTCOMES ------------------------------------------- - - None. - - ---- STATISTICS --------------------------------------------------------------- +expect_stdout = """\ +%(python)s -tt test/fail.py +FAILING TEST STDOUT +""" % locals() - 1 (100%) tests as expected +expect_stderr = """\ +FAILING TEST STDERR """ -test.run(arguments = '-b . test/fail.py', status = 1, stdout = expect) +test.run(arguments='-b . test/fail.py', + status=1, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/baseline/no_result.py b/test/runtest/baseline/no_result.py index d1c0f75..8641c90 100644 --- a/test/runtest/baseline/no_result.py +++ b/test/runtest/baseline/no_result.py @@ -30,32 +30,27 @@ Test how we handle a no-results test specified on the command line. import TestRuntest +python = TestRuntest.python + test = TestRuntest.TestRuntest() test.subdir('test') test.write_no_result_test(['test', 'no_result.py']) -expect = r"""qmtest run --output baseline.qmr --format none --result-stream="scons_tdb.AegisBaselineStream" test/no_result.py ---- TEST RESULTS ------------------------------------------------------------- - - test/no_result.py : NO_RESULT - - NO RESULT TEST STDOUT - - NO RESULT TEST STDERR - ---- TESTS WITH UNEXPECTED OUTCOMES ------------------------------------------- - - test/no_result.py : NO_RESULT - - ---- STATISTICS --------------------------------------------------------------- +expect_stdout = """\ +%(python)s -tt test/no_result.py +NO RESULT TEST STDOUT +""" % locals() - 1 (100%) tests unexpected NO_RESULT +expect_stderr = """\ +NO RESULT TEST STDERR """ -test.run(arguments = '-b . test/no_result.py', status = 1, stdout = expect) +test.run(arguments='-b . test/no_result.py', + status=2, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/baseline/pass.py b/test/runtest/baseline/pass.py index 3644052..ef3a99e 100644 --- a/test/runtest/baseline/pass.py +++ b/test/runtest/baseline/pass.py @@ -30,30 +30,26 @@ Test how we handle a passing test specified on the command line. import TestRuntest +python = TestRuntest.python + test = TestRuntest.TestRuntest() test.subdir('test') test.write_passing_test(['test', 'pass.py']) -# NOTE: The "test/pass.py : PASS" line has spaces at the end. - -expect = r"""qmtest run --output baseline.qmr --format none --result-stream="scons_tdb.AegisBaselineStream" test/pass.py ---- TEST RESULTS ------------------------------------------------------------- - - test/pass.py : PASS - ---- TESTS WITH UNEXPECTED OUTCOMES ------------------------------------------- - - test/pass.py : PASS - - ---- STATISTICS --------------------------------------------------------------- +expect_stdout = """\ +%(python)s -tt test/pass.py +PASSING TEST STDOUT +""" % locals() - 1 (100%) tests unexpected PASS +expect_stderr = """\ +PASSING TEST STDERR """ -test.run(arguments = '-b . test/pass.py', stdout = expect) +test.run(arguments='-b . test', + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/fallback.py b/test/runtest/fallback.py index d74ba6c..c7354a3 100644 --- a/test/runtest/fallback.py +++ b/test/runtest/fallback.py @@ -91,8 +91,6 @@ NO RESULT from the following test: """ % locals() expect_stderr = """\ -Warning: found neither qmtest nor qmtest.py on $PATH; -\tassuming --noqmtest option. FAILING TEST STDERR NO RESULT TEST STDERR PASSING TEST STDERR diff --git a/test/runtest/print_time.py b/test/runtest/print_time.py index 38a5bc6..54f90fe 100644 --- a/test/runtest/print_time.py +++ b/test/runtest/print_time.py @@ -35,6 +35,7 @@ import re import TestCmd import TestRuntest +python = TestRuntest.python test_fail_py = re.escape(os.path.join('test', 'fail.py')) test_no_result_py = re.escape(os.path.join('test', 'no_result.py')) test_pass_py = re.escape(os.path.join('test', 'pass.py')) @@ -49,49 +50,35 @@ test.write_no_result_test(['test', 'no_result.py']) test.write_passing_test(['test', 'pass.py']) -# NOTE: The "test/fail.py : FAIL" and "test/pass.py : PASS" lines both -# have spaces at the end. - -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream\(print_time='1'\)" test ---- TEST RESULTS ------------------------------------------------------------- - - %(test_fail_py)s : FAIL - - FAILING TEST STDOUT - - FAILING TEST STDERR - - Total execution time: \d+\.\d+ seconds - - %(test_no_result_py)s : NO_RESULT - - NO RESULT TEST STDOUT - - NO RESULT TEST STDERR - - Total execution time: \d+\.\d+ seconds - - %(test_pass_py)s : PASS - - Total execution time: \d+\.\d+ seconds - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - %(test_fail_py)s : FAIL - - %(test_no_result_py)s : NO_RESULT - - ---- STATISTICS --------------------------------------------------------------- - - 3 tests total - - 1 \( 33%%\) tests PASS - 1 \( 33%%\) tests FAIL - 1 \( 33%%\) tests NO_RESULT +expect_stdout = """\ +%(python)s -tt test/fail.py +FAILING TEST STDOUT +Test execution time: \\d+.\\d seconds +%(python)s -tt test/no_result.py +NO RESULT TEST STDOUT +Test execution time: \\d+.\\d seconds +%(python)s -tt test/pass.py +PASSING TEST STDOUT +Test execution time: \\d+.\\d seconds +Total execution time for all tests: \\d+.\\d seconds + +Failed the following test: +\ttest/fail.py + +NO RESULT from the following test: +\ttest/no_result.py """ % locals() -test.run(arguments = '-t test', status = 1, stdout = expect) +expect_stderr = """\ +FAILING TEST STDERR +NO RESULT TEST STDERR +PASSING TEST STDERR +""" + +test.run(arguments='-t test', + status=1, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/python.py b/test/runtest/python.py index 1830aa7..e798a53 100644 --- a/test/runtest/python.py +++ b/test/runtest/python.py @@ -48,26 +48,18 @@ test.subdir('test') test.write_passing_test(['test', 'pass.py']) -# NOTE: The "test/pass.py : PASS" line has spaces at the end. - -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" --context python="%(mypython)s" test ---- TEST RESULTS ------------------------------------------------------------- - - %(test_pass_py)s : PASS - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - None. - - ---- STATISTICS --------------------------------------------------------------- - - 1 tests total - - 1 (100%%) tests PASS +expect_stdout = """\ +%(mypython)s -tt test/pass.py +PASSING TEST STDOUT """ % locals() -test.run(arguments = ['-P', mypython, 'test'], stdout = expect) +expect_stderr = """\ +PASSING TEST STDERR +""" + +test.run(arguments=['-P', mypython, 'test'], + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/simple/combined.py b/test/runtest/simple/combined.py index 0c9997f..6794ea5 100644 --- a/test/runtest/simple/combined.py +++ b/test/runtest/simple/combined.py @@ -36,6 +36,7 @@ import TestRuntest test = TestRuntest.TestRuntest() +python = TestRuntest.python test_fail_py = os.path.join('test', 'fail.py') test_no_result_py = os.path.join('test', 'no_result.py') test_pass_py = os.path.join('test', 'pass.py') @@ -48,43 +49,31 @@ test.write_no_result_test(['test', 'no_result.py']) test.write_passing_test(['test', 'pass.py']) -# NOTE: The "test/fail.py : FAIL" and "test/pass.py : PASS" lines both -# have spaces at the end. +expect_stdout = """\ +%(python)s -tt test/fail.py +FAILING TEST STDOUT +%(python)s -tt test/no_result.py +NO RESULT TEST STDOUT +%(python)s -tt test/pass.py +PASSING TEST STDOUT -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" test ---- TEST RESULTS ------------------------------------------------------------- +Failed the following test: +\ttest/fail.py - %(test_fail_py)s : FAIL - - FAILING TEST STDOUT - - FAILING TEST STDERR - - %(test_no_result_py)s : NO_RESULT - - NO RESULT TEST STDOUT - - NO RESULT TEST STDERR - - %(test_pass_py)s : PASS - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - %(test_fail_py)s : FAIL - - %(test_no_result_py)s : NO_RESULT - - ---- STATISTICS --------------------------------------------------------------- - - 3 tests total - - 1 ( 33%%) tests PASS - 1 ( 33%%) tests FAIL - 1 ( 33%%) tests NO_RESULT +NO RESULT from the following test: +\ttest/no_result.py """ % locals() -test.run(arguments = 'test', status = 1, stdout = expect) +expect_stderr = """\ +FAILING TEST STDERR +NO RESULT TEST STDERR +PASSING TEST STDERR +""" + +test.run(arguments='test', + status=1, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/simple/fail.py b/test/runtest/simple/fail.py index f060f50..4a36c47 100644 --- a/test/runtest/simple/fail.py +++ b/test/runtest/simple/fail.py @@ -30,36 +30,27 @@ Test how we handle a failing test specified on the command line. import TestRuntest +python = TestRuntest.python + test = TestRuntest.TestRuntest() test.subdir('test') test.write_failing_test(['test', 'fail.py']) -# NOTE: The "test/fail.py : FAIL" line has spaces at the end. - -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" test/fail.py ---- TEST RESULTS ------------------------------------------------------------- - - test/fail.py : FAIL - - FAILING TEST STDOUT - - FAILING TEST STDERR - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - test/fail.py : FAIL - - ---- STATISTICS --------------------------------------------------------------- - - 1 tests total +expect_stdout = """\ +%(python)s -tt test/fail.py +FAILING TEST STDOUT +""" % locals() - 1 (100%) tests FAIL +expect_stderr = """\ +FAILING TEST STDERR """ -test.run(arguments = 'test/fail.py', status = 1, stdout = expect) +test.run(arguments='test/fail.py', + status=1, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/simple/no_result.py b/test/runtest/simple/no_result.py index 55d6f0e..475c5a8 100644 --- a/test/runtest/simple/no_result.py +++ b/test/runtest/simple/no_result.py @@ -30,34 +30,27 @@ Test how we handle a no-results test specified on the command line. import TestRuntest +python = TestRuntest.python + test = TestRuntest.TestRuntest() test.subdir('test') test.write_no_result_test(['test', 'no_result.py']) -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" test/no_result.py ---- TEST RESULTS ------------------------------------------------------------- - - test/no_result.py : NO_RESULT - - NO RESULT TEST STDOUT - - NO RESULT TEST STDERR - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - test/no_result.py : NO_RESULT - - ---- STATISTICS --------------------------------------------------------------- - - 1 tests total +expect_stdout = """\ +%(python)s -tt test/no_result.py +NO RESULT TEST STDOUT +""" % locals() - 1 (100%) tests NO_RESULT +expect_stderr = """\ +NO RESULT TEST STDERR """ -test.run(arguments = 'test/no_result.py', status = 1, stdout = expect) +test.run(arguments='test/no_result.py', + status=2, + stdout=expect_stdout, + stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/simple/pass.py b/test/runtest/simple/pass.py index ee7bc74..873be09 100644 --- a/test/runtest/simple/pass.py +++ b/test/runtest/simple/pass.py @@ -30,32 +30,24 @@ Test how we handle a passing test specified on the command line. import TestRuntest +python = TestRuntest.python + test = TestRuntest.TestRuntest() test.subdir('test') test.write_passing_test(['test', 'pass.py']) -# NOTE: The "test/pass.py : PASS" line has spaces at the end. - -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" test/pass.py ---- TEST RESULTS ------------------------------------------------------------- - - test/pass.py : PASS - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - None. - - ---- STATISTICS --------------------------------------------------------------- - - 1 tests total +expect_stdout = """\ +%(python)s -tt test/pass.py +PASSING TEST STDOUT +""" % locals() - 1 (100%) tests PASS +expect_stderr = """\ +PASSING TEST STDERR """ -test.run(arguments = 'test/pass.py', stdout = expect) +test.run(arguments='test/pass.py', stdout=expect_stdout, stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/src.py b/test/runtest/src.py index 70d10f0..18db972 100644 --- a/test/runtest/src.py +++ b/test/runtest/src.py @@ -33,11 +33,12 @@ import os.path import TestRuntest -test = TestRuntest.TestRuntest(verbose=1) +test = TestRuntest.TestRuntest() test.subdir(['src'], ['src', 'suite']) +python = TestRuntest.python src_passTests_py = os.path.join('src', 'passTests.py') src_suite_passTests_py = os.path.join('src', 'suite', 'passTests.py') @@ -49,29 +50,19 @@ test.write_passing_test(['src', 'suite', 'pass.py']) test.write_passing_test(['src', 'suite', 'passTests.py']) -# NOTE: The "test/pass.py : PASS" and "test/passTests.py : PASS" lines -# both have spaces at the end. - -expect = r"""qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" src ---- TEST RESULTS ------------------------------------------------------------- - - %(src_passTests_py)s : PASS - - %(src_suite_passTests_py)s : PASS - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - None. - - ---- STATISTICS --------------------------------------------------------------- - - 2 tests total +expect_stdout = """\ +%(python)s -tt src/passTests.py +PASSING TEST STDOUT +%(python)s -tt src/suite/passTests.py +PASSING TEST STDOUT +""" % locals() - 2 (100%%) tests PASS +expect_stderr = """\ +PASSING TEST STDERR +PASSING TEST STDERR """ % locals() -test.run(arguments = 'src', stdout = expect) +test.run(arguments='src', stdout=expect_stdout, stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/testlistfile.py b/test/runtest/testlistfile.py index a9d2565..dc78c29 100644 --- a/test/runtest/testlistfile.py +++ b/test/runtest/testlistfile.py @@ -32,6 +32,7 @@ import os.path import TestRuntest +python = TestRuntest.python test_fail_py = os.path.join('test', 'fail.py') test_no_result_py = os.path.join('test', 'no_result.py') test_pass_py = os.path.join('test', 'pass.py') @@ -51,27 +52,16 @@ test.write('t.txt', """\ %(test_pass_py)s """ % locals()) -# NOTE: The "test/fail.py : FAIL" and "test/pass.py : PASS" lines both -# have spaces at the end. - -expect = """qmtest run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" %(test_pass_py)s ---- TEST RESULTS ------------------------------------------------------------- - - %(test_pass_py)s : PASS - ---- TESTS THAT DID NOT PASS -------------------------------------------------- - - None. - - ---- STATISTICS --------------------------------------------------------------- - - 1 tests total - - 1 (100%%) tests PASS +expect_stdout = """\ +%(python)s -tt test/pass.py +PASSING TEST STDOUT """ % locals() -test.run(arguments = '-f t.txt', stdout = expect) +expect_stderr = """\ +PASSING TEST STDERR +""" + +test.run(arguments='-f t.txt', stdout=expect_stdout, stderr=expect_stderr) test.pass_test() diff --git a/test/runtest/xml/output.py b/test/runtest/xml/output.py index 52b718a..3641d22 100644 --- a/test/runtest/xml/output.py +++ b/test/runtest/xml/output.py @@ -32,10 +32,12 @@ import os.path import re import sys +import TestCmd import TestRuntest -test = TestRuntest.TestRuntest() +test = TestRuntest.TestRuntest(match = TestCmd.match_re) +python = TestRuntest.python test_fail_py = re.escape(os.path.join('test', 'fail.py')) test_no_result_py = re.escape(os.path.join('test', 'no_result.py')) test_pass_py = re.escape(os.path.join('test', 'pass.py')) @@ -58,135 +60,45 @@ test.write_no_result_test(['test', 'no_result.py']) test.write_passing_test(['test', 'pass.py']) -test.run(arguments = '-o xml.out --xml test', status = 1) - -expect_engine = """\ -<annotation key="scons_test\\.engine"> - __build__='D456' - __buildsys__='another_fake_system' - __date__='Dec 31 1999' - __developer__='John Doe' - __version__='4\\.5\\.6' -</annotation> -""" - -expect_script = """\ -<annotation key="scons_test\\.script"> - __build__='D123' - __buildsys__='fake_system' - __date__='Jan 1 1970' - __developer__='Anonymous' - __version__='1\\.2\\.3' -</annotation> -""" - -# The actual values printed for sys and os.environ will be completely -# dependent on the local values. Don't bother trying to match, just -# look to see if the opening tag exists. - -expect_sys = """\ -<annotation key="scons_test\\.sys"> -""" - -expect_os_environ = """\ -<annotation key="scons_test\\.os\\.environ"> -""" - -expect_fail = """\ - <result id="%(test_fail_py)s" kind="test" outcome="FAIL"> - <annotation name="Test\\.exit_code"> - "1" - </annotation> - <annotation name="Test\\.stderr"> - "<pre>FAILING TEST STDERR%(cr)s -</pre>" - </annotation> - <annotation name="Test\\.stdout"> - "<pre>FAILING TEST STDOUT%(cr)s -</pre>" - </annotation> - <annotation name="qmtest\\.cause"> - "Non-zero exit_code\\." - </annotation> - <annotation name="qmtest\\.end_time"> - "[\\d.]+" - </annotation> - <annotation name="qmtest\\.start_time"> - "[\\d.]+" - </annotation> - <annotation name="qmtest\\.target"> - "local" - </annotation> - </result> -""" % locals() - -expect_no_result = """\ - <result id="%(test_no_result_py)s" kind="test" outcome="FAIL"> - <annotation name="Test.exit_code"> - "2" - </annotation> - <annotation name="Test\\.stderr"> - "<pre>NO RESULT TEST STDERR%(cr)s -</pre>" - </annotation> - <annotation name="Test\\.stdout"> - "<pre>NO RESULT TEST STDOUT%(cr)s -</pre>" - </annotation> - <annotation name="qmtest\\.cause"> - "Non-zero exit_code\\." - </annotation> - <annotation name="qmtest\\.end_time"> - "[\\d.]+" - </annotation> - <annotation name="qmtest\\.start_time"> - "[\\d.]+" - </annotation> - <annotation name="qmtest\\.target"> - "local" - </annotation> - </result> -""" % locals() - -expect_pass = """\ - <result id="%(test_pass_py)s" kind="test" outcome="PASS"> - <annotation name="qmtest\\.end_time"> - "[\\d.]+" - </annotation> - <annotation name="qmtest\\.start_time"> - "[\\d.]+" - </annotation> - <annotation name="qmtest\\.target"> - "local" - </annotation> - </result> +test.run(arguments = '-o xml.out --xml test', status=1) + +expect = """\ + <results> + <test> + <file_name>test/fail.py</file_name> + <command_line>%(python)s -tt test/fail.py</command_line> + <exit_status>1</exit_status> + <stdout>FAILING TEST STDOUT +</stdout> + <stderr>FAILING TEST STDERR +</stderr> + <time>\\d+\.\d</time> + </test> + <test> + <file_name>test/no_result.py</file_name> + <command_line>%(python)s -tt test/no_result.py</command_line> + <exit_status>2</exit_status> + <stdout>NO RESULT TEST STDOUT +</stdout> + <stderr>NO RESULT TEST STDERR +</stderr> + <time>\\d+\.\d</time> + </test> + <test> + <file_name>test/pass.py</file_name> + <command_line>%(python)s -tt test/pass.py</command_line> + <exit_status>0</exit_status> + <stdout>PASSING TEST STDOUT +</stdout> + <stderr>PASSING TEST STDERR +</stderr> + <time>\\d+\.\d</time> + </test> + <time>\\d+\.\d</time> + </results> """ % locals() -xml_out = test.read('xml.out', 'r') - -expect = [ - expect_engine, - expect_script, - expect_sys, - expect_os_environ, - expect_fail, - expect_no_result, - expect_pass, -] - -non_matches = [] - -for e in expect: - if not re.search(e, xml_out): - non_matches.append(e) - -if non_matches: - for n in non_matches: - print "DID NOT MATCH " + '='*60 - print n - print "ACTUAL XML OUTPUT " + '='*60 - print xml_out - test.fail_test() +test.must_match('xml.out', expect) test.pass_test() |