summaryrefslogtreecommitdiff
path: root/test/runtest
diff options
context:
space:
mode:
Diffstat (limited to 'test/runtest')
-rw-r--r--test/runtest/baseline/combined.py83
-rw-r--r--test/runtest/baseline/fail.py61
-rw-r--r--test/runtest/baseline/no_result.py61
-rw-r--r--test/runtest/baseline/pass.py63
-rw-r--r--test/runtest/fallback.py96
-rw-r--r--test/runtest/noqmtest.py88
-rw-r--r--test/runtest/print_time.py89
-rw-r--r--test/runtest/python.py81
-rw-r--r--test/runtest/simple/combined.py84
-rw-r--r--test/runtest/simple/fail.py61
-rw-r--r--test/runtest/simple/no_result.py61
-rw-r--r--test/runtest/simple/pass.py58
-rw-r--r--test/runtest/src.py73
-rw-r--r--test/runtest/testargv.py75
-rw-r--r--test/runtest/testlistfile.py73
-rw-r--r--test/runtest/xml/output.py106
16 files changed, 1213 insertions, 0 deletions
diff --git a/test/runtest/baseline/combined.py b/test/runtest/baseline/combined.py
new file mode 100644
index 000000000..35c1796bb
--- /dev/null
+++ b/test/runtest/baseline/combined.py
@@ -0,0 +1,83 @@
+#!/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__"
+
+"""
+Test a combination of a passing test, failing test, and no-result
+test with no argument on the command line.
+"""
+
+import os
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+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')
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_failing_test(['test', 'fail.py'])
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+test.write_passing_test(['test', 'pass.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_fail_py)s
+FAILING TEST STDOUT
+%(pythonstring)s -tt %(test_no_result_py)s
+NO RESULT TEST STDOUT
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+
+Failed the following test:
+\t%(test_fail_py)s
+
+NO RESULT from the following test:
+\t%(test_no_result_py)s
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+NO RESULT TEST STDERR
+PASSING TEST STDERR
+"""
+
+test.run(arguments='-k -b . test',
+ status=1,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/baseline/fail.py b/test/runtest/baseline/fail.py
new file mode 100644
index 000000000..56871607a
--- /dev/null
+++ b/test/runtest/baseline/fail.py
@@ -0,0 +1,61 @@
+#!/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__"
+
+"""
+Test how we handle a failing test specified on the command line.
+"""
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_failing_test(['test', 'fail.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt test/fail.py
+FAILING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+"""
+
+test.run(arguments='-k -b . test/fail.py',
+ status=1,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/baseline/no_result.py b/test/runtest/baseline/no_result.py
new file mode 100644
index 000000000..2149594ff
--- /dev/null
+++ b/test/runtest/baseline/no_result.py
@@ -0,0 +1,61 @@
+#!/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__"
+
+"""
+Test how we handle a no-results test specified on the command line.
+"""
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt test/no_result.py
+NO RESULT TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+NO RESULT TEST STDERR
+"""
+
+test.run(arguments='-k -b . test/no_result.py',
+ status=2,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/baseline/pass.py b/test/runtest/baseline/pass.py
new file mode 100644
index 000000000..affa4860a
--- /dev/null
+++ b/test/runtest/baseline/pass.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__"
+
+"""
+Test how we handle a passing test specified on the command line.
+"""
+
+import os
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+test_pass_py = os.path.join('test', 'pass.py')
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_passing_test(['test', 'pass.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+PASSING TEST STDERR
+"""
+
+test.run(arguments='-k -b . test',
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/fallback.py b/test/runtest/fallback.py
new file mode 100644
index 000000000..1229b28ed
--- /dev/null
+++ b/test/runtest/fallback.py
@@ -0,0 +1,96 @@
+#!/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__"
+
+"""
+Test that runtest.py falls back (with a warning) using --noqmtest
+if it can't find qmtest on the $PATH.
+"""
+
+import os
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+# qmtest may be in more than one location in your path
+while test.where_is('qmtest'):
+ qmtest=test.where_is('qmtest')
+ dir = os.path.split(qmtest)[0]
+ path = os.environ['PATH'].split(os.pathsep)
+ path.remove(dir)
+ os.environ['PATH'] = os.pathsep.join(path)
+
+test.subdir('test')
+
+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')
+
+test.write_failing_test(test_fail_py)
+test.write_no_result_test(test_no_result_py)
+test.write_passing_test(test_pass_py)
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_fail_py)s
+FAILING TEST STDOUT
+%(pythonstring)s -tt %(test_no_result_py)s
+NO RESULT TEST STDOUT
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+
+Failed the following test:
+\t%(test_fail_py)s
+
+NO RESULT from the following test:
+\t%(test_no_result_py)s
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+NO RESULT TEST STDERR
+PASSING TEST STDERR
+"""
+
+testlist = [
+ test_fail_py,
+ test_no_result_py,
+ test_pass_py,
+]
+
+test.run(arguments = '-k '+' '.join(testlist),
+ status = 1,
+ stdout = expect_stdout,
+ stderr = expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/noqmtest.py b/test/runtest/noqmtest.py
new file mode 100644
index 000000000..cea2f116c
--- /dev/null
+++ b/test/runtest/noqmtest.py
@@ -0,0 +1,88 @@
+#!/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__"
+
+"""
+Test that by default tests are invoked directly via Python, not
+using qmtest.
+"""
+
+import os
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+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')
+
+test.write_failing_test(test_fail_py)
+test.write_no_result_test(test_no_result_py)
+test.write_passing_test(test_pass_py)
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_fail_py)s
+FAILING TEST STDOUT
+%(pythonstring)s -tt %(test_no_result_py)s
+NO RESULT TEST STDOUT
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+
+Failed the following test:
+\t%(test_fail_py)s
+
+NO RESULT from the following test:
+\t%(test_no_result_py)s
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+NO RESULT TEST STDERR
+PASSING TEST STDERR
+"""
+
+testlist = [
+ test_fail_py,
+ test_no_result_py,
+ test_pass_py,
+]
+
+test.run(arguments = '-k %s' % ' '.join(testlist),
+ status = 1,
+ stdout = expect_stdout,
+ stderr = expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/print_time.py b/test/runtest/print_time.py
new file mode 100644
index 000000000..244c6f8ed
--- /dev/null
+++ b/test/runtest/print_time.py
@@ -0,0 +1,89 @@
+#!/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__"
+
+"""
+Test a combination of a passing test, failing test, and no-result
+test with no argument on the command line.
+"""
+
+import os
+import re
+
+import TestCmd
+import TestRuntest
+
+pythonstring = re.escape(TestRuntest.pythonstring)
+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'))
+
+test = TestRuntest.TestRuntest(match = TestCmd.match_re)
+
+test.subdir('test')
+
+test.write_failing_test(['test', 'fail.py'])
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+test.write_passing_test(['test', 'pass.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_fail_py)s
+FAILING TEST STDOUT
+Test execution time: \\d+.\\d seconds
+%(pythonstring)s -tt %(test_no_result_py)s
+NO RESULT TEST STDOUT
+Test execution time: \\d+.\\d seconds
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+Test execution time: \\d+.\\d seconds
+Total execution time for all tests: \\d+.\\d seconds
+
+Failed the following test:
+\t%(test_fail_py)s
+
+NO RESULT from the following test:
+\t%(test_no_result_py)s
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+NO RESULT TEST STDERR
+PASSING TEST STDERR
+"""
+
+test.run(arguments='-k -t test',
+ status=1,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/python.py b/test/runtest/python.py
new file mode 100644
index 000000000..bcbc0625b
--- /dev/null
+++ b/test/runtest/python.py
@@ -0,0 +1,81 @@
+#!/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__"
+
+"""
+Test that the -P option lets us specify a Python version to use.
+"""
+
+import os
+import re
+
+if not hasattr(os.path, 'pardir'):
+ os.path.pardir = '..'
+
+import TestRuntest
+
+test = TestRuntest.TestRuntest()
+
+test_pass_py = os.path.join('test', 'pass.py')
+
+head, python = os.path.split(TestRuntest.python)
+head, dir = os.path.split(head)
+
+# 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('\\', '\\\\')
+
+if re.search('\s', mypython):
+ mypythonstring = '"%s"' % escape(mypython)
+else:
+ mypythonstring = escape(mypython)
+
+test.subdir('test')
+
+test.write_passing_test(['test', 'pass.py'])
+
+expect_stdout = """\
+%(mypythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+PASSING TEST STDERR
+"""
+
+test.run(arguments=['-k','-P', mypython, 'test'],
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/simple/combined.py b/test/runtest/simple/combined.py
new file mode 100644
index 000000000..616f4d533
--- /dev/null
+++ b/test/runtest/simple/combined.py
@@ -0,0 +1,84 @@
+
+#!/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__"
+
+"""
+Test a combination of a passing test, failing test, and no-result
+test with no argument on the command line.
+"""
+
+import os
+
+import TestRuntest
+
+test = TestRuntest.TestRuntest()
+
+pythonstring = TestRuntest.pythonstring
+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')
+
+test.subdir('test')
+
+test.write_failing_test(['test', 'fail.py'])
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+test.write_passing_test(['test', 'pass.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_fail_py)s
+FAILING TEST STDOUT
+%(pythonstring)s -tt %(test_no_result_py)s
+NO RESULT TEST STDOUT
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+
+Failed the following test:
+\t%(test_fail_py)s
+
+NO RESULT from the following test:
+\t%(test_no_result_py)s
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+NO RESULT TEST STDERR
+PASSING TEST STDERR
+"""
+
+test.run(arguments='-k test',
+ status=1,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/simple/fail.py b/test/runtest/simple/fail.py
new file mode 100644
index 000000000..8b800fb43
--- /dev/null
+++ b/test/runtest/simple/fail.py
@@ -0,0 +1,61 @@
+#!/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__"
+
+"""
+Test how we handle a failing test specified on the command line.
+"""
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_failing_test(['test', 'fail.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt test/fail.py
+FAILING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+FAILING TEST STDERR
+"""
+
+test.run(arguments='-k test/fail.py',
+ status=1,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/simple/no_result.py b/test/runtest/simple/no_result.py
new file mode 100644
index 000000000..91af7e459
--- /dev/null
+++ b/test/runtest/simple/no_result.py
@@ -0,0 +1,61 @@
+#!/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__"
+
+"""
+Test how we handle a no-results test specified on the command line.
+"""
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt test/no_result.py
+NO RESULT TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+NO RESULT TEST STDERR
+"""
+
+test.run(arguments='-k test/no_result.py',
+ status=2,
+ stdout=expect_stdout,
+ stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/simple/pass.py b/test/runtest/simple/pass.py
new file mode 100644
index 000000000..6e5b6b041
--- /dev/null
+++ b/test/runtest/simple/pass.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__"
+
+"""
+Test how we handle a passing test specified on the command line.
+"""
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_passing_test(['test', 'pass.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt test/pass.py
+PASSING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+PASSING TEST STDERR
+"""
+
+test.run(arguments='-k test/pass.py', stdout=expect_stdout, stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/src.py b/test/runtest/src.py
new file mode 100644
index 000000000..23894f99e
--- /dev/null
+++ b/test/runtest/src.py
@@ -0,0 +1,73 @@
+#!/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 we find tests under the src/ tree only if they end
+with *Tests.py.
+"""
+
+import os
+
+import TestRuntest
+
+test = TestRuntest.TestRuntest()
+
+test.subdir(['src'],
+ ['src', 'suite'])
+
+pythonstring = TestRuntest.pythonstring
+src_passTests_py = os.path.join('src', 'passTests.py')
+src_suite_passTests_py = os.path.join('src', 'suite', 'passTests.py')
+
+test.write_passing_test(['src', 'pass.py'])
+
+test.write_passing_test(['src', 'passTests.py'])
+
+test.write_passing_test(['src', 'suite', 'pass.py'])
+
+test.write_passing_test(['src', 'suite', 'passTests.py'])
+
+expect_stdout = """\
+%(pythonstring)s -tt %(src_passTests_py)s
+PASSING TEST STDOUT
+%(pythonstring)s -tt %(src_suite_passTests_py)s
+PASSING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+PASSING TEST STDERR
+PASSING TEST STDERR
+""" % locals()
+
+test.run(arguments='-k src', stdout=expect_stdout, stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/testargv.py b/test/runtest/testargv.py
new file mode 100644
index 000000000..62faf51b5
--- /dev/null
+++ b/test/runtest/testargv.py
@@ -0,0 +1,75 @@
+#!/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__"
+
+"""
+Test subdir args for runtest.py, for example:
+
+ python runtest.py test/subdir
+
+"""
+
+import os
+
+import TestRuntest
+
+test = TestRuntest.TestRuntest()
+test.subdir('test', ['test', 'subdir'])
+
+files = {}
+files['pythonstring'] = TestRuntest.pythonstring
+
+files['one'] = os.path.join('test/subdir', 'test_one.py')
+files['two'] = os.path.join('test/subdir', 'two.py')
+files['three'] = os.path.join('test', 'test_three.py')
+
+test.write_passing_test(files['one'])
+test.write_passing_test(files['two'])
+test.write_passing_test(files['three'])
+
+expect_stdout = """\
+%(pythonstring)s -tt %(one)s
+PASSING TEST STDOUT
+%(pythonstring)s -tt %(two)s
+PASSING TEST STDOUT
+""" % files
+
+expect_stderr = """\
+PASSING TEST STDERR
+PASSING TEST STDERR
+"""
+
+test.run(arguments = '--no-progress test/subdir',
+ status = 0,
+ stdout = expect_stdout,
+ stderr = expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/testlistfile.py b/test/runtest/testlistfile.py
new file mode 100644
index 000000000..b86b0f210
--- /dev/null
+++ b/test/runtest/testlistfile.py
@@ -0,0 +1,73 @@
+#!/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__"
+
+"""
+Test a list of tests to run in a file specified with the -f option.
+"""
+
+import os.path
+import re
+
+import TestRuntest
+
+pythonstring = TestRuntest.pythonstring
+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')
+
+test = TestRuntest.TestRuntest()
+
+test.subdir('test')
+
+test.write_failing_test(['test', 'fail.py'])
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+test.write_passing_test(['test', 'pass.py'])
+
+test.write('t.txt', """\
+#%(test_fail_py)s
+%(test_pass_py)s
+""" % locals())
+
+expect_stdout = """\
+%(pythonstring)s -tt %(test_pass_py)s
+PASSING TEST STDOUT
+""" % locals()
+
+expect_stderr = """\
+PASSING TEST STDERR
+"""
+
+test.run(arguments='-k -f t.txt', stdout=expect_stdout, stderr=expect_stderr)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/runtest/xml/output.py b/test/runtest/xml/output.py
new file mode 100644
index 000000000..66d7911fd
--- /dev/null
+++ b/test/runtest/xml/output.py
@@ -0,0 +1,106 @@
+#!/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__"
+
+"""
+Test writing XML output to a file.
+"""
+
+import os
+import re
+
+import TestCmd
+import TestRuntest
+
+test = TestRuntest.TestRuntest(match = TestCmd.match_re,
+ diff = TestCmd.diff_re)
+
+pythonstring = re.escape(TestRuntest.pythonstring)
+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'))
+
+test.subdir('test')
+
+test.write_fake_scons_source_tree()
+
+test.write_failing_test(['test', 'fail.py'])
+
+test.write_no_result_test(['test', 'no_result.py'])
+
+test.write_passing_test(['test', 'pass.py'])
+
+test.run(arguments = '--xml xml.out test', status=1)
+
+expect = """\
+ <results>
+ <test>
+ <file_name>%(test_fail_py)s</file_name>
+ <command_line>%(pythonstring)s -tt %(test_fail_py)s</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)s</file_name>
+ <command_line>%(pythonstring)s -tt %(test_no_result_py)s</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)s</file_name>
+ <command_line>%(pythonstring)s -tt %(test_pass_py)s</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()
+
+# Just strip carriage returns so the regular expression matching works.
+contents = test.read('xml.out')
+contents = contents.replace('\r', '')
+test.write('xml.out', contents)
+
+test.must_match('xml.out', expect)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: