Bug 510553: make trace-test.py use correct program argv passing and path separator conventions, r=jorendorff

This commit is contained in:
David Mandelin 2009-08-14 12:09:42 -07:00
Родитель 9dcc251822
Коммит 8c08ec6bc0
1 изменённых файлов: 10 добавлений и 8 удалений

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

@ -40,16 +40,17 @@ def get_test_cmd(path, lib_dir):
libdir_var = lib_dir libdir_var = lib_dir
if not libdir_var.endswith('/'): if not libdir_var.endswith('/'):
libdir_var += '/' libdir_var += '/'
expr = 'const platform="%s"; const libdir="%s";'%(sys.platform, libdir_var) expr = "const platform=%r; const libdir=%r;"%(sys.platform, libdir_var)
cmd = '%s -j -e \'%s\' -f %s -f %s'%( return [ JS, '-j', '-e', expr, '-f', os.path.join(lib_dir, 'prolog.js'),
JS, expr, os.path.join(lib_dir, 'prolog.js'), path) '-f', path ]
return cmd
def run_test(path, lib_dir): def run_test(path, lib_dir):
cmd = get_test_cmd(path, lib_dir) cmd = get_test_cmd(path, lib_dir)
if OPTIONS.show_cmd: if OPTIONS.show_cmd:
print(cmd) print(cmd)
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) # close_fds is not supported on Windows and will cause a ValueError.
close_fds = sys.platform != 'win32'
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=close_fds)
out, err = p.communicate() out, err = p.communicate()
out, err = out.decode(), err.decode() out, err = out.decode(), err.decode()
if OPTIONS.show_output: if OPTIONS.show_output:
@ -135,19 +136,20 @@ if __name__ == '__main__':
(OPTIONS, args) = op.parse_args() (OPTIONS, args) = op.parse_args()
if len(args) < 1: if len(args) < 1:
op.error('missing JS_SHELL argument') op.error('missing JS_SHELL argument')
JS, test_args = args[0], args[1:] # We need to make sure we are using backslashes on Windows.
JS, test_args = os.path.normpath(args[0]), args[1:]
if test_args: if test_args:
test_list = [] test_list = []
for arg in test_args: for arg in test_args:
test_list += find_tests(os.path.join(test_dir, arg)) test_list += find_tests(os.path.normpath(os.path.join(test_dir, arg)))
else: else:
test_list = find_tests(test_dir) test_list = find_tests(test_dir)
if OPTIONS.exclude: if OPTIONS.exclude:
exclude_list = [] exclude_list = []
for exclude in OPTIONS.exclude: for exclude in OPTIONS.exclude:
exclude_list += find_tests(os.path.join(test_dir, exclude)) exclude_list += find_tests(os.path.normpath(os.path.join(test_dir, exclude)))
test_list = [ test for test in test_list if test not in set(exclude_list) ] test_list = [ test for test in test_list if test not in set(exclude_list) ]
if not test_list: if not test_list: