Skip to content

Commit 583ba3f

Browse files
committed
fixup! esm: print required top-level await locations without evaluating
1 parent 148ebd7 commit 583ba3f

5 files changed

Lines changed: 13 additions & 9 deletions

‎test/common/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ function expectRequiredTLAError(err) {
957957
// Extract the entries of the rendered "Require stack:" list (each shown as
958958
// "- <path>") from an error message or a process output string.
959959
function parseRequireStack(output) {
960-
const lines = output.split('\n');
960+
const lines = output.replace(/\r/g, '').split('\n');
961961
const start = lines.indexOf('Require stack:');
962962
if (start === -1) {
963963
return [];

‎test/es-module/test-require-module-tla-print-arrow.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ const fixtures = require('../common/fixtures');
1616
signal: null,
1717
status: 1,
1818
stderr(output) {
19+
output = output.replace(/\r/g, '');
1920
common.expectRequiredTLAError(output);
2021
// Indented await: the caret is aligned under the await.
21-
assert.ok(output.includes(' await Promise.resolve(ready);\n ^'), output);
22+
assert(output.includes(' await Promise.resolve(ready);\n ^'), output);
2223
// for-await-of: the caret points at the for keyword.
23-
assert.ok(output.includes('for await (const x of [Promise.resolve(1)]) {\n^'), output);
24+
assert(output.includes('for await (const x of [Promise.resolve(1)]) {\n^'), output);
2425
return true;
2526
},
2627
stdout: '',

‎test/es-module/test-require-module-tla-print-execution.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ const fixtures = require('../common/fixtures');
1717
signal: null,
1818
status: 1,
1919
stderr(output) {
20+
output = output.replace(/\r/g, '');
2021
assert.doesNotMatch(output, /I am executed/);
2122
common.expectRequiredTLAError(output);
2223
// The location of the top-level await is shown with a caret.
23-
assert.match(output, /tla\/execution\.mjs:3/);
24-
assert.ok(output.includes("await Promise.resolve('hi');\n^"), output);
24+
assert(output.includes(`${fixtures.path('es-modules/tla/execution.mjs')}:3`), output);
25+
assert(output.includes("await Promise.resolve('hi');\n^"), output);
2526
// The require() chain is shown as a require stack.
2627
assert.match(output, /Require stack:/);
2728
assert.match(output, /require-execution\.js/);

‎test/es-module/test-require-module-tla-print-nested.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ const fixtures = require('../common/fixtures');
1717
signal: null,
1818
status: 1,
1919
stderr(output) {
20+
output = output.replace(/\r/g, '');
2021
common.expectRequiredTLAError(output);
2122
// The top-level await lives in a transitive dependency (a.mjs).
22-
assert.match(output, /tla\/a\.mjs:3/);
23-
assert.ok(output.includes('await new Promise((resolve) => {\n^'), output);
23+
assert(output.includes(`${fixtures.path('es-modules/tla/a.mjs')}:3`), output);
24+
assert(output.includes('await new Promise((resolve) => {\n^'), output);
2425
assert.match(output, /Require stack:/);
2526
assert.match(output, /require-nested\.js/);
2627
return true;

‎test/es-module/test-require-module-tla-print-preload.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ const fixtures = require('../common/fixtures');
1818
signal: null,
1919
status: 1,
2020
stderr(output) {
21+
output = output.replace(/\r/g, '');
2122
// The main script should not run because preloading fails first.
2223
assert.doesNotMatch(output, /main ran/);
2324
assert.doesNotMatch(output, /I am executed/);
2425
common.expectRequiredTLAError(output);
25-
assert.match(output, /tla\/execution\.mjs:3/);
26-
assert.ok(output.includes("await Promise.resolve('hi');\n^"), output);
26+
assert(output.includes(`${fixtures.path('es-modules/tla/execution.mjs')}:3`), output);
27+
assert(output.includes("await Promise.resolve('hi');\n^"), output);
2728
return true;
2829
},
2930
stdout: '',

0 commit comments

Comments
 (0)