mirror of https://github.com/vitalif/phantomjs
Add support for selective test execution.
If there are any positional arguments to test/run-tests.py, they are matched (verbatim, not as regular expressions) against each test's name. Only those tests whose names contain at least one of the positional arguments will be run. Thus, for instance, you can run just the webpage tests with ./test/run-tests.py module/webpage or one specific test with ./test/run-tests.py exact/name/of/test.js or the basics and standards tests with ./test/run-tests.py basics standards If no tests at all match, run-tests.py will print "ALL TESTS SKIPPED" and exit unsuccessfully. Ongoing work on issue #12439.2.0
parent
4d60e9450d
commit
767494dc35
|
@ -184,12 +184,14 @@ def init():
|
|||
www_path = os.path.join(base_path, 'www')
|
||||
|
||||
parser = optparse.OptionParser(
|
||||
usage='%prog [options]',
|
||||
usage='%prog [options] [tests to run...]',
|
||||
description='Run PhantomJS tests.'
|
||||
)
|
||||
parser.add_option('--verbose', action='store_true', default=False, help='Show a verbose log')
|
||||
(options, args) = parser.parse_args(sys.argv[1:])
|
||||
|
||||
options.to_run = args
|
||||
|
||||
if options.verbose:
|
||||
returncode, version = run_phantomjs('--version')
|
||||
print 'Checking PhantomJS version %s' % version
|
||||
|
@ -245,30 +247,45 @@ def run_test(script, name):
|
|||
def run_tests():
|
||||
setup_server()
|
||||
if not http_running:
|
||||
return
|
||||
return 1
|
||||
|
||||
start = time.time()
|
||||
if options.verbose:
|
||||
print 'Starting the tests...'
|
||||
print
|
||||
|
||||
result = 0
|
||||
any_executed = False
|
||||
for test_group in TESTS:
|
||||
test_group_name = os.path.dirname(test_group)
|
||||
test_glob = os.path.normpath(base_path + '/' + test_group)
|
||||
|
||||
if options.verbose:
|
||||
print 'Test group: %s...' % test_group_name
|
||||
print
|
||||
print 'Test group: %s...' % test_group_name
|
||||
|
||||
for test_script in glob.glob(test_glob):
|
||||
tname = test_group_name + '/' + os.path.basename(test_script)
|
||||
if options.to_run:
|
||||
for to_run in options.to_run:
|
||||
if to_run in tname:
|
||||
break
|
||||
else:
|
||||
if options.verbose:
|
||||
print "%s: skipped" % tname
|
||||
continue
|
||||
|
||||
any_executed = True
|
||||
ret = run_test(test_script, tname)
|
||||
if ret != 0:
|
||||
print 'The test %s FAILED' % tname
|
||||
print
|
||||
result = 1
|
||||
|
||||
if not any_executed:
|
||||
result = 1
|
||||
print
|
||||
print 'ALL TESTS SKIPPED.'
|
||||
|
||||
if result == 0:
|
||||
print
|
||||
print 'No failure. Finished in %d seconds.' % (time.time() - start)
|
||||
|
|
Loading…
Reference in New Issue