Bug 638219 - Set all test-independent command-line bits up once, pass in; r=terrence

This will help integration with the jstests framework, which also uses
a single prefix argument to its Test command construction method.

Note that the order of js arguments is changed, from:

    cmd = [js] + list(set(self.jitflags)) + shell_args + ['-e', expr]
    cmd += ['-f', os.path.join(LIB_DIR, 'prolog.js'), '-f', self.path]

to:

    prefix = [os.path.abspath(args[0])] + shlex.split(options.shell_args)
    prefix += ['-f', os.path.join(jittests.LIB_DIR, 'prolog.js')]
    cmd = prefix + list(set(self.jitflags)) + ['-e', expr, '-f', self.path]

The assumption here is that only the order of -f options matters.

--HG--
extra : rebase_source : 9655d6efc62006aa840d72f6b31d764bd870cc7d
This commit is contained in:
Dirkjan Ochtman 2013-02-15 17:58:45 +01:00
Родитель eaeeefdc15
Коммит bbda60f654
2 изменённых файлов: 20 добавлений и 22 удалений

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

@ -79,7 +79,7 @@ def main(argv):
if len(args) < 1:
op.error('missing JS_SHELL argument')
# We need to make sure we are using backslashes on Windows.
options.js_shell, test_args = os.path.abspath(args[0]), args[1:]
test_args = args[:1]
if jittests.stdio_might_be_broken():
# Prefer erring on the side of caution and not using stdio if
@ -174,8 +174,8 @@ def main(argv):
new_test.jitflags.extend(jitflags)
job_list.append(new_test)
shell_args = shlex.split(options.shell_args)
prefix = [os.path.abspath(args[0])] + shlex.split(options.shell_args)
prefix += ['-f', os.path.join(jittests.LIB_DIR, 'prolog.js')]
if options.debug:
if len(job_list) > 1:
print 'Multiple tests match command line arguments, debugger can only run one'
@ -184,21 +184,21 @@ def main(argv):
sys.exit(1)
tc = job_list[0]
cmd = [ 'gdb', '--args' ] + tc.command(options.js_shell, shell_args)
cmd = ['gdb', '--args'] + tc.command(prefix)
subprocess.call(cmd)
sys.exit()
try:
ok = None
if options.max_jobs > 1 and jittests.HAVE_MULTIPROCESSING:
ok = jittests.run_tests_parallel(job_list, shell_args, options)
ok = jittests.run_tests_parallel(job_list, prefix, options)
else:
ok = jittests.run_tests(job_list, shell_args, options)
ok = jittests.run_tests(job_list, prefix, options)
if not ok:
sys.exit(2)
except OSError:
if not os.path.exists(options.js_shell):
print >> sys.stderr, "JS shell argument: file does not exist: '%s'" % options.js_shell
if not os.path.exists(prefix[0]):
print >> sys.stderr, "JS shell argument: file does not exist: '%s'" % prefix[0]
sys.exit(1)
else:
raise

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

@ -145,7 +145,7 @@ class Test:
return test
def command(self, js, shell_args):
def command(self, prefix):
scriptdir_var = os.path.dirname(self.path);
if not scriptdir_var.endswith('/'):
scriptdir_var += '/'
@ -153,8 +153,7 @@ class Test:
% (sys.platform, LIB_DIR, scriptdir_var))
# We may have specified '-a' or '-d' twice: once via --jitflags, once
# via the "|jit-test|" line. Remove dups because they are toggles.
cmd = [js] + list(set(self.jitflags)) + shell_args + ['-e', expr]
cmd += ['-f', os.path.join(LIB_DIR, 'prolog.js'), '-f', self.path]
cmd = prefix + list(set(self.jitflags)) + ['-e', expr, '-f', self.path]
if self.valgrind:
cmd = self.VALGRIND_CMD + cmd
return cmd
@ -261,8 +260,8 @@ def run_cmd_avoid_stdio(cmdline, env, timeout):
_, __, code = run_timeout_cmd(cmdline, { 'env': env }, timeout)
return read_and_unlink(stdoutPath), read_and_unlink(stderrPath), code
def run_test(test, shell_args, options):
cmd = test.command(options.js_shell, shell_args)
def run_test(test, prefix, options):
cmd = test.command(prefix)
if options.show_cmd:
print(subprocess.list2cmdline(cmd))
@ -308,14 +307,14 @@ def print_tinderbox(label, test, message=None):
result += ": " + message
print(result)
def wrap_parallel_run_test(test, shell_args, resultQueue, options):
def wrap_parallel_run_test(test, prefix, resultQueue, options):
# Ignore SIGINT in the child
signal.signal(signal.SIGINT, signal.SIG_IGN)
result = run_test(test, shell_args, options)
result = run_test(test, prefix, options)
resultQueue.put(result)
return result
def run_tests_parallel(tests, shell_args, options):
def run_tests_parallel(tests, prefix, options):
# This queue will contain the results of the various tests run.
# We could make this queue a global variable instead of using
# a manager to share, but this will not work on Windows.
@ -363,7 +362,7 @@ def run_tests_parallel(tests, shell_args, options):
while notify_queue.get():
if (testcnt < len(tests)):
# Start one new worker
worker_process = Process(target=wrap_parallel_run_test, args=(tests[testcnt], shell_args, async_test_result_queue, options))
worker_process = Process(target=wrap_parallel_run_test, args=(tests[testcnt], prefix, async_test_result_queue, options))
worker_processes.append(worker_process)
worker_process.start()
testcnt += 1
@ -519,13 +518,12 @@ def process_test_results(results, num_tests, options):
pb.finish(True)
return print_test_summary(failures, complete, doing, options)
def get_serial_results(tests, shell_args, options):
def get_serial_results(tests, prefix, options):
for test in tests:
yield run_test(test, shell_args, options)
yield run_test(test, prefix, options)
def run_tests(tests, shell_args, options):
gen = get_serial_results(tests, shell_args, options)
def run_tests(tests, prefix, options):
gen = get_serial_results(tests, prefix, options)
ok = process_test_results(gen, len(tests), options)
return ok