Support globs in run-tests.py#TESTS.

This means that there is no longer a need to add every individual test
to the list; only new *directories* have to be mentioned.  New tests
can be added just by dropping .js files into appropriate directories.

Tests which are not meant to be run by default now live in tests/manual/.
Currently there is one such test, tests/manual/standards/ecma-test262.js,
which downloads and runs the ECMAScript conformance suite.

Ongoing work on issue #12439.
2.0
Zack Weinberg 2014-09-12 13:57:26 -04:00
parent 83f4baf8c6
commit 1adbbe4830
2 changed files with 23 additions and 38 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import inspect import inspect
import glob
import json import json
import optparse import optparse
import os import os
@ -21,34 +22,11 @@ HTTP_PORT = 9180
http_running = False http_running = False
TESTS = [ TESTS = [
'basics/exit.js', 'basics/*.js',
'basics/global.js', 'module/system/*.js',
'basics/onerror.js', 'module/webpage/*.js',
'basics/stacktrace.js', 'standards/javascript/*.js',
'basics/version.js', 'regression/*.js',
'module/webpage/open.js',
'module/webpage/loading.js',
'module/webpage/custom-headers.js',
'module/webpage/add-header.js',
'module/webpage/remove-header.js',
'module/webpage/modify-header.js',
'module/webpage/repaint-requested.js',
'module/webpage/change-request-url.js',
'module/webpage/change-request-encoded-url.js',
'module/webpage/abort-network-request.js',
'module/webpage/resource-request-error.js',
'module/webpage/resource-received-error.js',
'module/webpage/no-plugin.js',
'module/system/system.js',
'module/system/args.js',
'module/system/os.js',
'module/system/pid.js',
'module/system/stdout.js',
'module/system/stdin.js',
'module/system/stderr.js',
'standards/javascript/date.js',
'standards/javascript/function.js',
'regression/issue12482.js',
'run-tests.js' 'run-tests.js'
] ]
@ -205,19 +183,17 @@ def run_phantomjs(script, args=[]):
return process.returncode, '\n'.join(output) return process.returncode, '\n'.join(output)
def run_test(filename): def run_test(script, name):
script = os.path.normpath(base_path + '/' + filename)
args = [] args = []
if options.verbose: if options.verbose:
args.append('--verbose') args.append('--verbose')
result = 0 result = 0
if not os.path.isfile(script): if not os.path.isfile(script):
print 'Could not locate %s' % filename print 'Could not locate %s' % name
result = 1 result = 1
else: else:
print '%s:' % filename print '%s:' % name
returncode, output = run_phantomjs(script, args) returncode, output = run_phantomjs(script, args)
if returncode != 0: if returncode != 0:
if not options.verbose: if not options.verbose:
@ -238,12 +214,21 @@ def run_tests():
print print
result = 0 result = 0
for test in TESTS: for test_group in TESTS:
ret = run_test(test) test_group_name = os.path.dirname(test_group)
if ret != 0: test_glob = os.path.normpath(base_path + '/' + test_group)
print 'The test %s FAILED' % test
if options.verbose:
print 'Test group: %s...' % test_group_name
print print
result = 1
for test_script in glob.glob(test_glob):
tname = test_group_name + '/' + os.path.basename(test_script)
ret = run_test(test_script, tname)
if ret != 0:
print 'The test %s FAILED' % tname
print
result = 1
if result == 0: if result == 0:
print print