Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! esm: print required top-level await locations without evaluating
  • Loading branch information
joyeecheung committed Jul 1, 2026
commit 583ba3fd0f5d9e597b2330afc2c3ef84717e3ab7
2 changes: 1 addition & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ function expectRequiredTLAError(err) {
// Extract the entries of the rendered "Require stack:" list (each shown as
// "- <path>") from an error message or a process output string.
function parseRequireStack(output) {
const lines = output.split('\n');
const lines = output.replace(/\r/g, '').split('\n');
const start = lines.indexOf('Require stack:');
if (start === -1) {
return [];
Expand Down
5 changes: 3 additions & 2 deletions test/es-module/test-require-module-tla-print-arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const fixtures = require('../common/fixtures');
signal: null,
status: 1,
stderr(output) {
output = output.replace(/\r/g, '');
common.expectRequiredTLAError(output);
// Indented await: the caret is aligned under the await.
assert.ok(output.includes(' await Promise.resolve(ready);\n ^'), output);
assert(output.includes(' await Promise.resolve(ready);\n ^'), output);
// for-await-of: the caret points at the for keyword.
assert.ok(output.includes('for await (const x of [Promise.resolve(1)]) {\n^'), output);
assert(output.includes('for await (const x of [Promise.resolve(1)]) {\n^'), output);
return true;
},
stdout: '',
Expand Down
5 changes: 3 additions & 2 deletions test/es-module/test-require-module-tla-print-execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ const fixtures = require('../common/fixtures');
signal: null,
status: 1,
stderr(output) {
output = output.replace(/\r/g, '');
assert.doesNotMatch(output, /I am executed/);
common.expectRequiredTLAError(output);
// The location of the top-level await is shown with a caret.
assert.match(output, /tla\/execution\.mjs:3/);
assert.ok(output.includes("await Promise.resolve('hi');\n^"), output);
assert(output.includes(`${fixtures.path('es-modules/tla/execution.mjs')}:3`), output);
assert(output.includes("await Promise.resolve('hi');\n^"), output);
// The require() chain is shown as a require stack.
assert.match(output, /Require stack:/);
assert.match(output, /require-execution\.js/);
Expand Down
5 changes: 3 additions & 2 deletions test/es-module/test-require-module-tla-print-nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ const fixtures = require('../common/fixtures');
signal: null,
status: 1,
stderr(output) {
output = output.replace(/\r/g, '');
common.expectRequiredTLAError(output);
// The top-level await lives in a transitive dependency (a.mjs).
assert.match(output, /tla\/a\.mjs:3/);
assert.ok(output.includes('await new Promise((resolve) => {\n^'), output);
assert(output.includes(`${fixtures.path('es-modules/tla/a.mjs')}:3`), output);
assert(output.includes('await new Promise((resolve) => {\n^'), output);
assert.match(output, /Require stack:/);
assert.match(output, /require-nested\.js/);
return true;
Expand Down
5 changes: 3 additions & 2 deletions test/es-module/test-require-module-tla-print-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ const fixtures = require('../common/fixtures');
signal: null,
status: 1,
stderr(output) {
output = output.replace(/\r/g, '');
// The main script should not run because preloading fails first.
assert.doesNotMatch(output, /main ran/);
assert.doesNotMatch(output, /I am executed/);
common.expectRequiredTLAError(output);
assert.match(output, /tla\/execution\.mjs:3/);
assert.ok(output.includes("await Promise.resolve('hi');\n^"), output);
assert(output.includes(`${fixtures.path('es-modules/tla/execution.mjs')}:3`), output);
assert(output.includes("await Promise.resolve('hi');\n^"), output);
return true;
},
stdout: '',
Expand Down
Loading