Fix run-test262 dynamic import (#237)
Make basename imports resolve relative to the file under test.
This commit is contained in:
parent
440fc1b96b
commit
64c9ac5392
2 changed files with 15 additions and 4 deletions
|
@ -820,6 +820,19 @@ static JSModuleDef *js_module_loader_test(JSContext *ctx,
|
|||
uint8_t *buf;
|
||||
JSModuleDef *m;
|
||||
JSValue func_val;
|
||||
char *filename, *slash, path[1024];
|
||||
|
||||
// interpret import("bar.js") from path/to/foo.js as
|
||||
// import("path/to/bar.js") but leave import("./bar.js") untouched
|
||||
filename = opaque;
|
||||
if (!strchr(module_name, '/')) {
|
||||
slash = strrchr(filename, '/');
|
||||
if (slash) {
|
||||
snprintf(path, sizeof(path), "%.*s/%s",
|
||||
(int) (slash - filename), filename, module_name);
|
||||
module_name = path;
|
||||
}
|
||||
}
|
||||
|
||||
buf = js_load_file(ctx, &buf_len, module_name);
|
||||
if (!buf) {
|
||||
|
@ -1555,7 +1568,7 @@ int run_test_buf(const char *filename, char *harness, namelist_t *ip,
|
|||
JS_SetCanBlock(rt, can_block);
|
||||
|
||||
/* loader for ES6 modules */
|
||||
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader_test, NULL);
|
||||
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader_test, (void *) filename);
|
||||
|
||||
add_helpers(ctx);
|
||||
|
||||
|
@ -1851,7 +1864,7 @@ int run_test262_harness_test(const char *filename, BOOL is_module)
|
|||
JS_SetCanBlock(rt, can_block);
|
||||
|
||||
/* loader for ES6 modules */
|
||||
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader_test, NULL);
|
||||
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader_test, (void *) filename);
|
||||
|
||||
add_helpers(ctx);
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ test262/test/language/expressions/assignment/target-member-computed-reference-nu
|
|||
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
||||
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: Test262Error: Expected a DummyError but got a TypeError
|
||||
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
||||
test262/test/language/expressions/dynamic-import/usage-from-eval.js:26: TypeError: $DONE() not called
|
||||
test262/test/language/expressions/dynamic-import/usage-from-eval.js:26: strict mode: TypeError: $DONE() not called
|
||||
test262/test/language/expressions/function/static-init-await-binding.js:16: SyntaxError: 'await' is a reserved identifier
|
||||
test262/test/language/expressions/function/static-init-await-binding.js:16: strict mode: SyntaxError: 'await' is a reserved identifier
|
||||
test262/test/language/expressions/generators/static-init-await-binding.js:16: SyntaxError: 'await' is a reserved identifier
|
||||
|
|
Loading…
Reference in a new issue