summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2014-03-23 14:10:22 -0400
committerGary Oberbrunner <garyo@oberbrunner.com>2014-03-23 14:10:22 -0400
commit805a16fb52e3b4cf0edc098c85c959fa2b813426 (patch)
treeacd2a2e70a6c2f314399e8608212af56636acc23
parente5f4320c57085e8530da92b3d173cd1cfae3d601 (diff)
parent116eef839e018bbdd867311fddf1cfc1f8a10d8c (diff)
downloadscons-805a16fb52e3b4cf0edc098c85c959fa2b813426.tar.gz
Merged in dirkbaechle/scons (pull request #121)
Fixes for doc toolchain
-rwxr-xr-xruntest.py91
-rw-r--r--test/runtest/qmtest.py111
2 files changed, 49 insertions, 153 deletions
diff --git a/runtest.py b/runtest.py
index 2e349699..eee88dc5 100755
--- a/runtest.py
+++ b/runtest.py
@@ -6,8 +6,9 @@
#
# SCons test suite consists of:
#
-# - unit tests - included in *Tests.py files from src/ dir
-# - module tests - are in test/ dir and use framework from QMTest/
+# - unit tests - included in *Tests.py files from src/ dir
+# - end-to-end tests - these are *.py files in test/ directory that
+# require custom SCons framework from QMTest/
#
# This script adds src/ and QMTest/ directories to PYTHONPATH,
# performs test discovery and processes them according to options.
@@ -18,10 +19,9 @@
#
# -3 Run with the python -3 option,
#
-# -a Run all tests; does a virtual 'find' for
-# all SCons tests under the current directory.
-# You can also specify a list of subdirectories. Then,
-# only the given folders are searched for test files.
+# -a Run all tests found under the current directory.
+# It is also possible to specify a list of
+# subdirectories to search.
#
# -d Debug. Runs the script under the Python
# debugger (pdb.py) so you don't have to
@@ -33,8 +33,6 @@
# -f file Only execute the tests listed in the specified
# file.
#
-# -h Print the help and exit.
-#
# -k Suppress printing of count and percent progress for
# the single tests.
#
@@ -124,29 +122,30 @@ suppress_stderr = False
allow_pipe_files = True
quit_on_failure = False
-helpstr = """\
+usagestr = """\
Usage: runtest.py [OPTIONS] [TEST ...]
+ runtest.py -h|--help
+"""
+helpstr = usagestr + """\
Options:
-3 Warn about Python 3.x incompatibilities.
- -a, --all Run all tests.
- -b BASE, --baseline BASE Run test scripts against baseline BASE.
- --builddir DIR Directory in which packages were built.
- -d, --debug Run test scripts under the Python debugger.
- -e, --external Run the script in external mode (for testing separate Tools)
- -f FILE, --file FILE Run tests in specified FILE.
- -h, --help Print this message and exit.
- -k, --no-progress Suppress count and percent progress messages.
- -l, --list List available tests and exit.
- -n, --no-exec No execute, just print command lines.
- --nopipefiles Doesn't use the "file pipe" workaround for subprocess.Popen()
+ -a --all Run all tests.
+ -b --baseline BASE Run test scripts against baseline BASE.
+ --builddir DIR Directory in which packages were built.
+ -d --debug Run test scripts under the Python debugger.
+ -e --external Run the script in external mode (for testing separate Tools)
+ -f --file FILE Run tests in specified FILE.
+ -k --no-progress Suppress count and percent progress messages.
+ -l --list List available tests and exit.
+ -n --no-exec No execute, just print command lines.
+ --nopipefiles Doesn't use the "file pipe" workaround for subprocess.Popen()
for starting tests. WARNING: Only use this when too much file
traffic is giving you trouble AND you can be sure that none of
your tests create output that exceed 65K chars! You might
run into some deadlocks else.
- -o FILE, --output FILE Save the output from a test run to the log file.
- -P Python Use the specified Python interpreter.
- -p PACKAGE, --package PACKAGE
- Test against the specified PACKAGE:
+ -o --output FILE Save the output from a test run to the log file.
+ -P PYTHON Use the specified Python interpreter.
+ -p --package PACKAGE Test against the specified PACKAGE:
deb Debian
local-tar-gz .tar.gz standalone package
local-zip .zip standalone package
@@ -155,25 +154,25 @@ Options:
src-zip .zip source package
tar-gz .tar.gz distribution
zip .zip distribution
- --passed Summarize which tests passed.
- -q, --quiet Don't print the test being executed.
- --quit-on-failure Quit on any test failure
- -s, --short-progress Short progress, prints only the command line
+ --passed Summarize which tests passed.
+ -q --quiet Don't print the test being executed.
+ --quit-on-failure Quit on any test failure
+ -s --short-progress Short progress, prints only the command line
and a percentage value, based on the total and
current number of tests.
- -t, --time Print test execution time.
- -v version Specify the SCons version.
- --verbose=LEVEL Set verbose level: 1 = print executed commands,
+ -t --time Print test execution time.
+ -v VERSION Specify the SCons version.
+ --verbose=LEVEL Set verbose level: 1 = print executed commands,
2 = print commands and non-zero output,
3 = print commands and all output.
-X Test script is executable, don't feed to Python.
- -x SCRIPT, --exec SCRIPT Test SCRIPT.
- --xml file Save results to file in SCons XML format.
+ -x --exec SCRIPT Test SCRIPT.
+ --xml file Save results to file in SCons XML format.
Environment Variables:
PRESERVE, PRESERVE_{PASS,FAIL,NO_RESULT}: preserve test subdirs
- TESTCMD_VERBOSE: turn on verbosity in TestCommand
+ TESTCMD_VERBOSE: turn on verbosity in TestCommand\
"""
@@ -282,12 +281,10 @@ for o, a in opts:
scons = a
if not args and not options.all and not testlistfile:
- sys.stderr.write("""\
+ sys.stderr.write(usagestr + """
runtest.py: No tests were specified.
- List one or more tests on the command line, use the
- -f option to specify a file containing a list of tests,
- or use the -a option to find and run all tests.
-
+ Tests can be specified on the command line, read from file
+ with -f option, or discovered with -a to run all tests.
""")
sys.exit(1)
@@ -641,9 +638,13 @@ if old_pythonpath:
if python3incompatibilities:
os.environ['SCONS_HORRIBLE_REGRESSION_TEST_HACK'] = '1'
+
+# ---[ test discovery ]------------------------------------
+
tests = []
def find_Tests_py(directory):
+ """ Look for unit tests """
result = []
for dirpath, dirnames, filenames in os.walk(directory):
# Skip folders containing a sconstest.skip file
@@ -655,6 +656,7 @@ def find_Tests_py(directory):
return sorted(result)
def find_py(directory):
+ """ Look for end-to-end tests """
result = []
for dirpath, dirnames, filenames in os.walk(directory):
# Skip folders containing a sconstest.skip file
@@ -677,17 +679,20 @@ if args:
for path in glob.glob(a):
if os.path.isdir(path):
if path[:3] == 'src':
- tests.extend(find_Tests_py(path))
-
+ for p in find_Tests_py(path):
+ tests.append(p)
elif path[:4] == 'test':
- tests.extend(find_py(path))
+ for p in find_py(path):
+ tests.append(p)
else:
tests.append(path)
+
elif testlistfile:
tests = open(testlistfile, 'r').readlines()
tests = [x for x in tests if x[0] != '#']
tests = [x[:-1] for x in tests]
tests = [x.strip() for x in tests]
+
elif options.all:
# Find all of the SCons functional tests in the local directory
# tree. This is anything under the 'src' subdirectory that ends
@@ -711,6 +716,8 @@ runtest.py: No tests were found.
sys.exit(1)
+# ---[ test processing ]-----------------------------------
+
tests = [Test(t) for t in tests]
if list_only:
diff --git a/test/runtest/qmtest.py b/test/runtest/qmtest.py
deleted file mode 100644
index 4f158c4e..00000000
--- a/test/runtest/qmtest.py
+++ /dev/null
@@ -1,111 +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__"
-
-"""
-Test that the --qmtest option invokes tests directly via QMTest,
-not directly via Python.
-"""
-
-import os.path
-import sys
-
-if sys.platform == 'win32':
- qmtest_py = 'qmtest.py'
-else:
- qmtest_py = 'qmtest'
-
-import TestRuntest
-
-test = TestRuntest.TestRuntest()
-
-
-qmtest = test.where_is('qmtest')
-if not qmtest:
- test.skip_test("Could not find 'qmtest'; skipping test(s).\n")
-
-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)
-
-# NOTE: the FAIL and PASS lines below have trailing spaces.
-
-expect_stdout = """\
-%(qmtest_py)s run --output results.qmr --format none --result-stream="scons_tdb.AegisChangeStream" %(test_fail_py)s %(test_no_result_py)s %(test_pass_py)s
---- TEST RESULTS -------------------------------------------------------------
-
- %(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
-""" % locals()
-
-testlist = [
- test_fail_py,
- test_no_result_py,
- test_pass_py,
-]
-
-test.run(arguments='--qmtest %s' % ' '.join(testlist),
- status=1,
- stdout=expect_stdout)
-
-test.pass_test()
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4: