import os
import os.path
+import re
import string
import shutil
import sys
__all__.extend([ 'TestRuntest',
'python',
+ 'pythonstring',
'_python_',
])
python = python_executable
_python_ = '"' + python_executable + '"'
+if re.search('\s', python):
+ pythonstring = _python_
+else:
+ pythonstring = python
+pythonstring = string.replace(pythonstring, '\\', '\\\\')
+
failing_test_template = """\
import sys
Test writing Aegis batch output to a file.
"""
+import os
+
import TestRuntest
+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')
expect = """\
test_result = [
- { file_name = "test/fail.py";
+ { file_name = "%(test_fail_py)s";
exit_status = 1; },
- { file_name = "test/no_result.py";
+ { file_name = "%(test_no_result_py)s";
exit_status = 2; },
- { file_name = "test/pass.py";
+ { file_name = "%(test_pass_py)s";
exit_status = 0; },
];
-"""
+""" % locals()
# The mode is 'r' (not default 'rb') because QMTest opens the file
# description on which we write as non-binary.
-
#!/usr/bin/env python
#
# __COPYRIGHT__
test with no argument on the command line.
"""
-import os.path
+import os
import TestRuntest
-python = TestRuntest.python
+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.write_passing_test(['test', 'pass.py'])
expect_stdout = """\
-%(python)s -tt test/fail.py
+%(pythonstring)s -tt %(test_fail_py)s
FAILING TEST STDOUT
-%(python)s -tt test/no_result.py
+%(pythonstring)s -tt %(test_no_result_py)s
NO RESULT TEST STDOUT
-%(python)s -tt test/pass.py
+%(pythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
Failed the following test:
-\ttest/fail.py
+\t%(test_fail_py)s
NO RESULT from the following test:
-\ttest/no_result.py
+\t%(test_no_result_py)s
""" % locals()
expect_stderr = """\
import TestRuntest
-python = TestRuntest.python
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest()
test.write_failing_test(['test', 'fail.py'])
expect_stdout = """\
-%(python)s -tt test/fail.py
+%(pythonstring)s -tt test/fail.py
FAILING TEST STDOUT
""" % locals()
import TestRuntest
-python = TestRuntest.python
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest()
test.write_no_result_test(['test', 'no_result.py'])
expect_stdout = """\
-%(python)s -tt test/no_result.py
+%(pythonstring)s -tt test/no_result.py
NO RESULT TEST STDOUT
""" % locals()
Test how we handle a passing test specified on the command line.
"""
+import os
+
import TestRuntest
-python = TestRuntest.python
+pythonstring = TestRuntest.pythonstring
+test_pass_py = os.path.join('test', 'pass.py')
test = TestRuntest.TestRuntest()
test.write_passing_test(['test', 'pass.py'])
expect_stdout = """\
-%(python)s -tt test/pass.py
+%(pythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
""" % locals()
"""
import os
-import re
import string
import TestRuntest
-python = TestRuntest.python
-_python_ = TestRuntest._python_
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest(noqmtest=1)
test_no_result_py = os.path.join('test', 'no_result.py')
test_pass_py = os.path.join('test', 'pass.py')
-workpath_fail_py = test.workpath(test_fail_py)
-workpath_no_result_py = test.workpath(test_no_result_py)
-workpath_pass_py = test.workpath(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)
-if re.search('\s', python):
- expect_python = _python_
-else:
- expect_python = python
-
-def escape(s):
- return string.replace(s, '\\', '\\\\')
-
-expect_python = escape(expect_python)
-expect_workpath_fail_py = escape(test_fail_py)
-expect_workpath_no_result_py = escape(test_no_result_py)
-expect_workpath_pass_py = escape(test_pass_py)
-
expect_stdout = """\
-%(expect_python)s -tt %(expect_workpath_fail_py)s
+%(pythonstring)s -tt %(test_fail_py)s
FAILING TEST STDOUT
-%(expect_python)s -tt %(expect_workpath_no_result_py)s
+%(pythonstring)s -tt %(test_no_result_py)s
NO RESULT TEST STDOUT
-%(expect_python)s -tt %(expect_workpath_pass_py)s
+%(pythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
Failed the following test:
using qmtest.
"""
-import os.path
-import re
+import os
import string
import TestRuntest
-python = TestRuntest.python
-_python_ = TestRuntest._python_
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest(noqmtest=1)
test_no_result_py = os.path.join('test', 'no_result.py')
test_pass_py = os.path.join('test', 'pass.py')
-workpath_fail_py = test.workpath(test_fail_py)
-workpath_no_result_py = test.workpath(test_no_result_py)
-workpath_pass_py = test.workpath(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)
-if re.search('\s', python):
- expect_python = _python_
-else:
- expect_python = python
-
-def escape(s):
- return string.replace(s, '\\', '\\\\')
-
-expect_python = escape(expect_python)
-expect_workpath_fail_py = escape(test_fail_py)
-expect_workpath_no_result_py = escape(test_no_result_py)
-expect_workpath_pass_py = escape(test_pass_py)
-
expect_stdout = """\
-%(expect_python)s -tt %(expect_workpath_fail_py)s
+%(pythonstring)s -tt %(test_fail_py)s
FAILING TEST STDOUT
-%(expect_python)s -tt %(expect_workpath_no_result_py)s
+%(pythonstring)s -tt %(test_no_result_py)s
NO RESULT TEST STDOUT
-%(expect_python)s -tt %(expect_workpath_pass_py)s
+%(pythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
Failed the following test:
test with no argument on the command line.
"""
-import os.path
+import os
import re
import TestCmd
import TestRuntest
-python = TestRuntest.python
+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.write_passing_test(['test', 'pass.py'])
expect_stdout = """\
-%(python)s -tt test/fail.py
+%(pythonstring)s -tt %(test_fail_py)s
FAILING TEST STDOUT
Test execution time: \\d+.\\d seconds
-%(python)s -tt test/no_result.py
+%(pythonstring)s -tt %(test_no_result_py)s
NO RESULT TEST STDOUT
Test execution time: \\d+.\\d seconds
-%(python)s -tt test/pass.py
+%(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:
-\ttest/fail.py
+\t%(test_fail_py)s
NO RESULT from the following test:
-\ttest/no_result.py
+\t%(test_no_result_py)s
""" % locals()
expect_stderr = """\
Test that the -P option lets us specify a Python version to use.
"""
-import os.path
+import os
+import re
+import string
if not hasattr(os.path, 'pardir'):
os.path.pardir = '..'
mypython = os.path.join(head, dir, os.path.pardir, dir, python)
+def escape(s):
+ return string.replace(s, '\\', '\\\\')
+
+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 = """\
-%(mypython)s -tt test/pass.py
+%(mypythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
""" % locals()
test with no argument on the command line.
"""
-import os.path
+import os
import TestRuntest
test = TestRuntest.TestRuntest()
-python = TestRuntest.python
+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.write_passing_test(['test', 'pass.py'])
expect_stdout = """\
-%(python)s -tt test/fail.py
+%(pythonstring)s -tt %(test_fail_py)s
FAILING TEST STDOUT
-%(python)s -tt test/no_result.py
+%(pythonstring)s -tt %(test_no_result_py)s
NO RESULT TEST STDOUT
-%(python)s -tt test/pass.py
+%(pythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
Failed the following test:
-\ttest/fail.py
+\t%(test_fail_py)s
NO RESULT from the following test:
-\ttest/no_result.py
+\t%(test_no_result_py)s
""" % locals()
expect_stderr = """\
import TestRuntest
-python = TestRuntest.python
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest()
test.write_failing_test(['test', 'fail.py'])
expect_stdout = """\
-%(python)s -tt test/fail.py
+%(pythonstring)s -tt test/fail.py
FAILING TEST STDOUT
""" % locals()
import TestRuntest
-python = TestRuntest.python
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest()
test.write_no_result_test(['test', 'no_result.py'])
expect_stdout = """\
-%(python)s -tt test/no_result.py
+%(pythonstring)s -tt test/no_result.py
NO RESULT TEST STDOUT
""" % locals()
import TestRuntest
-python = TestRuntest.python
+pythonstring = TestRuntest.pythonstring
test = TestRuntest.TestRuntest()
test.write_passing_test(['test', 'pass.py'])
expect_stdout = """\
-%(python)s -tt test/pass.py
+%(pythonstring)s -tt test/pass.py
PASSING TEST STDOUT
""" % locals()
with *Tests.py.
"""
-import os.path
+import os
import TestRuntest
test.subdir(['src'],
['src', 'suite'])
-python = TestRuntest.python
+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', 'suite', 'passTests.py'])
expect_stdout = """\
-%(python)s -tt src/passTests.py
+%(pythonstring)s -tt %(src_passTests_py)s
PASSING TEST STDOUT
-%(python)s -tt src/suite/passTests.py
+%(pythonstring)s -tt %(src_suite_passTests_py)s
PASSING TEST STDOUT
""" % locals()
"""
import os.path
+import re
import TestRuntest
-python = TestRuntest.python
+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')
""" % locals())
expect_stdout = """\
-%(python)s -tt test/pass.py
+%(pythonstring)s -tt %(test_pass_py)s
PASSING TEST STDOUT
""" % locals()
Test writing XML output to a file.
"""
-import os.path
+import os
import re
-import sys
+import string
import TestCmd
import TestRuntest
test = TestRuntest.TestRuntest(match = TestCmd.match_re)
-python = TestRuntest.python
+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'))
-# sys.stdout and sys.stderr are open non-binary ('w' instead of 'wb')
-# so the lines written on Windows are terminated \r\n, not just \n. The
-# expressions below use 'cr' as the optional carriage return character.
-if sys.platform in ['win32']:
- cr = '\r'
-else:
- cr = ''
-
test.subdir('test')
test.write_fake_scons_source_tree()
expect = """\
<results>
<test>
- <file_name>test/fail.py</file_name>
- <command_line>%(python)s -tt test/fail.py</command_line>
+ <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>
<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>
+ <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>
<time>\\d+\.\d</time>
</test>
<test>
- <file_name>test/pass.py</file_name>
- <command_line>%(python)s -tt test/pass.py</command_line>
+ <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>