Bug 876776 - Add a -J option to the shell for running under jorendb, r=terrence

--HG--
extra : rebase_source : 60afc69f0c9ac65ab913797f8393779f3566ed2e
This commit is contained in:
Steve Fink 2013-06-04 12:14:17 -07:00
parent b22e1776a4
commit 6236142a93
2 changed files with 31 additions and 19 deletions

View File

@ -6,6 +6,7 @@ See the adjacent README.txt for more details.
"""
import os, sys, textwrap
from os.path import abspath, dirname, realpath
from copy import copy
from subprocess import list2cmdline, call
@ -89,6 +90,8 @@ def parse_args():
help='Example: --jitflags=m,amd to run each test with -m, -a -m -d [default=%default]')
harness_og.add_option('-g', '--debug', action='store_true', help='Run a test in debugger.')
harness_og.add_option('--debugger', default='gdb -q --args', help='Debugger command.')
harness_og.add_option('-J', '--jorendb', action='store_true', help='Run under JS debugger.')
harness_og.add_option('--passthrough', action='store_true', help='Run tests with stdin/stdout attached to caller.')
harness_og.add_option('--valgrind', action='store_true', help='Run tests in valgrind.')
harness_og.add_option('--valgrind-args', default='', help='Extra args to pass to valgrind.')
op.add_option_group(harness_og)
@ -135,7 +138,7 @@ def parse_args():
options.js_shell = None
requested_paths = set()
if len(args) > 0:
options.js_shell = os.path.abspath(args[0])
options.js_shell = abspath(args[0])
requested_paths |= set(args[1:])
# If we do not have a shell, we must be in a special mode.
@ -153,7 +156,15 @@ def parse_args():
if os.uname()[0] == 'Darwin':
prefix.append('--dsymutil=yes')
options.show_output = True
TestCase.set_js_cmd_prefix(options.js_shell, options.shell_args.split(), prefix)
js_cmd_args = options.shell_args.split()
if options.jorendb:
options.passthrough = True
options.hide_progress = True
options.worker_count = 1
debugger_path = realpath(os.path.join(abspath(dirname(abspath(__file__))), '..', '..', 'examples', 'jorendb.js'))
js_cmd_args.extend([ '-d', '-f', debugger_path, '--' ])
TestCase.set_js_cmd_prefix(options.js_shell, js_cmd_args, prefix)
# If files with lists of tests to run were specified, add them to the
# requested tests set.
@ -224,7 +235,7 @@ def load_tests(options, requested_paths, excluded_paths):
xul_info = manifest.XULInfo(xul_abi, xul_os, xul_debug)
xul_tester = manifest.XULInfoTester(xul_info, options.js_shell)
test_dir = os.path.dirname(os.path.abspath(__file__))
test_dir = dirname(abspath(__file__))
test_list = manifest.load(test_dir, xul_tester)
skip_list = []
@ -289,7 +300,7 @@ def main():
print 'no tests selected'
return 1
test_dir = os.path.dirname(os.path.abspath(__file__))
test_dir = dirname(abspath(__file__))
if options.debug:
if len(test_list) > 1:

View File

@ -17,25 +17,26 @@ class Task(object):
self.out = []
self.err = []
def spawn_test(test):
def spawn_test(test, passthrough = False):
"""Spawn one child, return a task struct."""
(rout, wout) = os.pipe()
(rerr, werr) = os.pipe()
if not passthrough:
(rout, wout) = os.pipe()
(rerr, werr) = os.pipe()
rv = os.fork()
rv = os.fork()
# Parent.
if rv:
os.close(wout)
os.close(werr)
return Task(test, rv, rout, rerr)
# Parent.
if rv:
os.close(wout)
os.close(werr)
return Task(test, rv, rout, rerr)
# Child.
os.close(rout)
os.close(rerr)
# Child.
os.close(rout)
os.close(rerr)
os.dup2(wout, 1)
os.dup2(werr, 2)
os.dup2(wout, 1)
os.dup2(werr, 2)
cmd = test.get_command(test.js_cmd_prefix)
os.execvp(cmd[0], cmd)
@ -188,7 +189,7 @@ def run_all_tests(tests, results, options):
while len(tests) or len(tasks):
while len(tests) and len(tasks) < options.worker_count:
tasks.append(spawn_test(tests.pop()))
tasks.append(spawn_test(tests.pop(), options.passthrough))
timeout = get_max_wait(tasks, results, options.timeout)
read_input(tasks, timeout)