diff --git a/test/build.py b/test/build.py index 69c1b19a26..94e7304dbf 100755 --- a/test/build.py +++ b/test/build.py @@ -13,6 +13,9 @@ WASM_EXEC = os.path.join(INTERPRETER_DIR, 'wasm') WAST_TESTS_DIR = os.path.join(SCRIPT_DIR, 'core') +WAST_TEST_SUBDIRS = [os.path.basename(d) for d in + filter(os.path.isdir, + glob.glob(os.path.join(WAST_TESTS_DIR, '*')))] HARNESS_DIR = os.path.join(SCRIPT_DIR, 'harness') HARNESS_FILES = ['testharness.js', 'testharnessreport.js', 'testharness.css'] @@ -67,13 +70,17 @@ def convert_wast_to_js(out_js_dir): inputs = [] - for wast_file in glob.glob(os.path.join(WAST_TESTS_DIR, '*.wast')): + for wast_file in glob.glob(os.path.join(WAST_TESTS_DIR, '**/*.wast'), + recursive = True): # Don't try to compile tests that are supposed to fail. if '.fail.' in wast_file: continue + js_subdir = os.path.basename(os.path.dirname(wast_file)) + if js_subdir == 'core': + js_subdir = '' js_filename = os.path.basename(wast_file) + '.js' - js_file = os.path.join(out_js_dir, js_filename) + js_file = os.path.join(out_js_dir, js_subdir, js_filename) inputs.append((wast_file, js_file)) pool = mp.Pool(processes=8) @@ -112,9 +119,9 @@ def build_js(out_js_dir): - - - + + +
""" @@ -137,6 +144,8 @@ def wrap_single_test(js_file): def build_html_js(out_dir): ensure_empty_dir(out_dir) + for d in WAST_TEST_SUBDIRS: + ensure_empty_dir(os.path.join(out_dir, d)) copy_harness_files(out_dir, True) tests = convert_wast_to_js(out_dir) @@ -146,19 +155,25 @@ def build_html_js(out_dir): def build_html_from_js(tests, html_dir, use_sync): for js_file in tests: - js_filename = os.path.basename(js_file) - html_filename = js_filename + '.html' - html_file = os.path.join(html_dir, html_filename) + subdir = os.path.basename(os.path.dirname(js_file)) + js_prefix = '../js' + if subdir == 'js': + subdir = '' + js_prefix = './js' + js_filename = os.path.join(js_prefix, subdir, os.path.basename(js_file)) + html_filename = os.path.basename(js_file) + '.html' + html_file = os.path.join(html_dir, subdir, html_filename) js_harness = "sync_index.js" if use_sync else "async_index.js" + harness_dir = os.path.join(js_prefix, 'harness') with open(html_file, 'w+') as f: - content = HTML_HEADER.replace('{PREFIX}', './js/harness') \ - .replace('{WPT_PREFIX}', './js/harness') \ + content = HTML_HEADER.replace('{PREFIX}', harness_dir) \ + .replace('{WPT_PREFIX}', harness_dir) \ .replace('{JS_HARNESS}', js_harness) - content += " ".replace('{SCRIPT}', js_filename) + content += ' ' content += HTML_BOTTOM f.write(content) -def build_html(html_dir, js_dir, use_sync): +def build_html(html_dir, use_sync): print("Building HTML tests...") js_html_dir = os.path.join(html_dir, 'js') @@ -248,11 +263,15 @@ def process_args(): if js_dir is not None: ensure_empty_dir(js_dir) + for d in WAST_TEST_SUBDIRS: + ensure_empty_dir(os.path.join(js_dir, d)) build_js(js_dir) if html_dir is not None: ensure_empty_dir(html_dir) - build_html(html_dir, js_dir, args.use_sync) + for d in WAST_TEST_SUBDIRS: + ensure_empty_dir(os.path.join(html_dir, d)) + build_html(html_dir, args.use_sync) if front_dir is not None: ensure_empty_dir(front_dir)