Bug 485736 - Add (TUnit) 'xpcshell-tests' |make| target, using |runxpcshelltests.py| new '--manifest' option; (Dv1a) Add |EXTRA_TEST_ARGS| support, enhance |--test| feature; r=ted.mielczarek

This commit is contained in:
Serge Gautherie 2009-04-28 01:37:02 +02:00
Родитель 2dafd2a338
Коммит c7ea3e37f3
2 изменённых файлов: 50 добавлений и 29 удалений

Просмотреть файл

@ -37,10 +37,23 @@
# ***** END LICENSE BLOCK *****
# Usage: |make [EXTRA_TEST_ARGS=...] mochitest*|.
# Shortcut for mochitest* and xpcshell-tests targets,
# replaces 'EXTRA_TEST_ARGS=--test-path=...'.
ifdef TEST_PATH
TEST_PATH_ARG := --test-path=$(TEST_PATH)
else
TEST_PATH_ARG :=
endif
# Usage: |make [TEST_PATH=...] [EXTRA_TEST_ARGS=...] mochitest*|.
mochitest:: mochitest-plain mochitest-chrome mochitest-a11y
RUN_MOCHITEST = rm -f ./$@.log && $(PYTHON) _tests/testing/mochitest/runtests.py --autorun --close-when-done --console-level=INFO --log-file=./$@.log --file-level=INFO $(MOCHITEST_PATH) $(EXTRA_TEST_ARGS)
RUN_MOCHITEST = \
rm -f ./$@.log && \
$(PYTHON) _tests/testing/mochitest/runtests.py --autorun --close-when-done \
--console-level=INFO --log-file=./$@.log --file-level=INFO \
$(TEST_PATH_ARG) $(EXTRA_TEST_ARGS)
ifndef NO_FAIL_ON_TEST_ERRORS
define CHECK_TEST_ERROR
@ -55,12 +68,6 @@ define CHECK_TEST_ERROR
endef
endif
ifdef TEST_PATH
MOCHITEST_PATH = --test-path=$(TEST_PATH)
else
MOCHITEST_PATH =
endif
mochitest-plain:
$(RUN_MOCHITEST)
$(CHECK_TEST_ERROR)
@ -88,10 +95,12 @@ crashtest:
# Execute all xpcshell tests in the directories listed in the manifest.
# See also config/rules.mk 'xpcshell-tests' target for local execution.
# Usage: |make [TEST_PATH=...] [EXTRA_TEST_ARGS=...] xpcshell-tests|.
xpcshell-tests:
$(PYTHON) -u \
$(topsrcdir)/testing/xpcshell/runxpcshelltests.py \
--manifest=$(DEPTH)/_tests/xpcshell/all-test-dirs.list \
$(TEST_PATH_ARG) $(EXTRA_TEST_ARGS) \
$(DIST)/bin/xpcshell

Просмотреть файл

@ -59,13 +59,13 @@ def readManifest(manifest):
pass # just eat exceptions
return testdirs
def runTests(xpcshell, testdirs=[], xrePath=None, testFile=None,
def runTests(xpcshell, testdirs=[], xrePath=None, testPath=None,
manifest=None, interactive=False):
"""Run the tests in |testdirs| using the |xpcshell| executable.
|xrePath|, if provided, is the path to the XRE to use.
|testFile|, if provided, indicates a single test to run.
|manifeest|, if provided, is a file containing a list of
|testPath|, if provided, indicates a single path and/or test to run.
|manifest|, if provided, is a file containing a list of
test directories to run.
|interactive|, if set to True, indicates to provide an xpcshell prompt
instead of automatically executing the test.
@ -125,15 +125,26 @@ def runTests(xpcshell, testdirs=[], xrePath=None, testFile=None,
if not interactive:
tailfiles += ['-e', '_execute_test();']
# when --test is specified, it can either be just a filename or
# testdir/filename. This is for convenience when there's only one
# test dir.
singleDir = None
if testFile and testFile.find('/') != -1:
# directory was specified
bits = testFile.split('/', 1)
singleDir = bits[0]
testFile = bits[1]
# |testPath| will be the optional path only, or |None|.
# |singleFile| will be the optional test only, or |None|.
singleFile = None
if testPath:
if testPath.endswith('.js'):
# Split into path and file.
if testPath.find('/') == -1:
# Test only.
singleFile = testPath
testPath = None
else:
# Both path and test.
# Reuse |testPath| temporarily.
testPath = testPath.rsplit('/', 1)
singleFile = testPath[1]
testPath = testPath[0]
else:
# Path only.
# Simply remove optional ending separator.
testPath = testPath.rstrip("/")
if manifest is not None:
testdirs = readManifest(os.path.abspath(manifest))
@ -141,8 +152,9 @@ def runTests(xpcshell, testdirs=[], xrePath=None, testFile=None,
# Process each test directory individually.
success = True
for testdir in testdirs:
if singleDir and singleDir != os.path.basename(testdir):
if testPath and not testdir.endswith(testPath):
continue
testdir = os.path.abspath(testdir)
# get the list of head and tail files from the directory
@ -157,9 +169,9 @@ def runTests(xpcshell, testdirs=[], xrePath=None, testFile=None,
# if a single test file was specified, we only want to execute that test
testfiles = sorted(glob(os.path.join(testdir, "test_*.js")))
if testFile:
if testFile in [os.path.basename(x) for x in testfiles]:
testfiles = [os.path.join(testdir, testFile)]
if singleFile:
if singleFile in [os.path.basename(x) for x in testfiles]:
testfiles = [os.path.join(testdir, singleFile)]
else: # not in this dir? skip it
continue
@ -206,9 +218,9 @@ def main():
parser.add_option("--xre-path",
action="store", type="string", dest="xrePath", default=None,
help="absolute path to directory containing XRE (probably xulrunner)")
parser.add_option("--test",
action="store", type="string", dest="testFile",
default=None, help="single test filename to test")
parser.add_option("--test-path",
action="store", type="string", dest="testPath",
default=None, help="single path and/or test filename to test")
parser.add_option("--interactive",
action="store_true", dest="interactive", default=False,
help="don't automatically run tests, drop to an xpcshell prompt")
@ -224,13 +236,13 @@ def main():
sys.argv[0])
sys.exit(1)
if options.interactive and not options.testFile:
if options.interactive and not options.testPath:
print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
sys.exit(1)
if not runTests(args[0], testdirs=args[1:],
xrePath=options.xrePath,
testFile=options.testFile,
testPath=options.testPath,
interactive=options.interactive,
manifest=options.manifest):
sys.exit(1)