Bug 638219 - Move command construction into Test class method; r=terrence

--HG--
rename : toolkit/modules/Timer.jsm => browser/devtools/shared/Browser.jsm
rename : toolkit/modules/tests/xpcshell/test_timer.js => browser/devtools/shared/test/browser_browser_basic.js
extra : rebase_source : 4a02112413b31457cf855d68a6db6d816172652f
This commit is contained in:
Dirkjan Ochtman 2013-02-15 08:32:43 +01:00
parent 54a8ab8389
commit da4c653309
2 changed files with 17 additions and 18 deletions

View File

@ -189,7 +189,7 @@ def main(argv):
sys.exit(1)
tc = job_list[0]
cmd = [ 'gdb', '--args' ] + jittests.get_test_cmd(options.js_shell, tc.path, tc.jitflags, lib_dir, shell_args)
cmd = [ 'gdb', '--args' ] + tc.command(options.js_shell, lib_dir, shell_args)
subprocess.call(cmd)
sys.exit()

View File

@ -123,6 +123,20 @@ class Test:
return test
def command(self, js, lib_dir, shell_args):
libdir_var = lib_dir
if not libdir_var.endswith('/'):
libdir_var += '/'
scriptdir_var = os.path.dirname(self.path);
if not scriptdir_var.endswith('/'):
scriptdir_var += '/'
expr = ("const platform=%r; const libdir=%r; const scriptdir=%r"
% (sys.platform, libdir_var, 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.
return ([js] + list(set(self.jitflags)) + shell_args +
['-e', expr, '-f', os.path.join(lib_dir, 'prolog.js'), '-f', self.path])
def find_tests(dir, substring = None):
ans = []
for dirpath, dirnames, filenames in os.walk(dir):
@ -140,20 +154,6 @@ def find_tests(dir, substring = None):
ans.append(test)
return ans
def get_test_cmd(js, path, jitflags, lib_dir, shell_args):
libdir_var = lib_dir
if not libdir_var.endswith('/'):
libdir_var += '/'
scriptdir_var = os.path.dirname(path);
if not scriptdir_var.endswith('/'):
scriptdir_var += '/'
expr = ("const platform=%r; const libdir=%r; const scriptdir=%r"
% (sys.platform, libdir_var, 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.
return ([js] + list(set(jitflags)) + shell_args +
[ '-e', expr, '-f', os.path.join(lib_dir, 'prolog.js'), '-f', path ])
def tmppath(token):
fd, path = tempfile.mkstemp(prefix=token)
os.close(fd)
@ -240,8 +240,7 @@ def run_cmd_avoid_stdio(cmdline, env, timeout):
return read_and_unlink(stdoutPath), read_and_unlink(stderrPath), code
def run_test(test, lib_dir, shell_args, options):
cmd = get_test_cmd(options.js_shell, test.path, test.jitflags, lib_dir, shell_args)
cmd = test.command(options.js_shell, lib_dir, shell_args)
if (test.valgrind and
any([os.path.exists(os.path.join(d, 'valgrind'))
for d in os.environ['PATH'].split(os.pathsep)])):
@ -442,7 +441,7 @@ def print_test_summary(failures, complete, doing, options, lib_dir, shell_args):
def show_test(test):
if options.show_failed:
print(' ' + subprocess.list2cmdline(get_test_cmd(options.js_shell, test.path, test.jitflags, lib_dir, shell_args)))
print(' ' + subprocess.list2cmdline(test.command(options.js_shell, lib_dir, shell_args)))
else:
print(' ' + ' '.join(test.jitflags + [test.path]))