From c8442efe5db4749ef758e73715aca7f103836593 Mon Sep 17 00:00:00 2001 From: Yiyun Lei Date: Tue, 29 Aug 2023 06:36:23 -0400 Subject: [PATCH] test: migrate message source map tests from Python to JS Migrate the remaining source map tests in the `test/message` folder from Python to JS. Fixes: https://github.com/nodejs/node/issues/47707 test: migrate message source map tests from Python to JS PR-URL: https://github.com/nodejs/node/pull/49238 Reviewed-By: Moshe Atlow --- .../output/source_map_enclosing_function.js | 7 +++++++ .../output/source_map_enclosing_function.snapshot} | 1 + .../output}/source_map_reference_error_tabs.js | 4 ++-- .../output/source_map_reference_error_tabs.snapshot | 10 ++++++++++ .../output}/source_map_sourcemapping_url_string.js | 4 ++-- .../source_map_sourcemapping_url_string.snapshot | 3 +++ .../source-map/output}/source_map_throw_catch.js | 4 ++-- .../source-map/output/source_map_throw_catch.snapshot | 4 ++++ .../source-map/output}/source_map_throw_icu.js | 4 ++-- .../source-map/output/source_map_throw_icu.snapshot | 10 ++++++++++ .../output/source_map_throw_set_immediate.js | 5 +++++ .../output/source_map_throw_set_immediate.snapshot | 11 +++++++++++ test/message/source_map_enclosing_function.js | 7 ------- test/message/source_map_reference_error_tabs.out | 9 --------- test/message/source_map_sourcemapping_url_string.out | 3 --- test/message/source_map_throw_catch.out | 4 ---- test/message/source_map_throw_icu.out | 9 --------- test/message/source_map_throw_set_immediate.js | 5 ----- test/message/source_map_throw_set_immediate.out | 10 ---------- test/parallel/test-node-output-sourcemaps.mjs | 6 ++++++ 20 files changed, 65 insertions(+), 55 deletions(-) create mode 100644 test/fixtures/source-map/output/source_map_enclosing_function.js rename test/{message/source_map_enclosing_function.out => fixtures/source-map/output/source_map_enclosing_function.snapshot} (99%) rename test/{message => fixtures/source-map/output}/source_map_reference_error_tabs.js (53%) create mode 100644 test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot rename test/{message => fixtures/source-map/output}/source_map_sourcemapping_url_string.js (61%) create mode 100644 test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot rename test/{message => fixtures/source-map/output}/source_map_throw_catch.js (66%) create mode 100644 test/fixtures/source-map/output/source_map_throw_catch.snapshot rename test/{message => fixtures/source-map/output}/source_map_throw_icu.js (54%) create mode 100644 test/fixtures/source-map/output/source_map_throw_icu.snapshot create mode 100644 test/fixtures/source-map/output/source_map_throw_set_immediate.js create mode 100644 test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot delete mode 100644 test/message/source_map_enclosing_function.js delete mode 100644 test/message/source_map_reference_error_tabs.out delete mode 100644 test/message/source_map_sourcemapping_url_string.out delete mode 100644 test/message/source_map_throw_catch.out delete mode 100644 test/message/source_map_throw_icu.out delete mode 100644 test/message/source_map_throw_set_immediate.js delete mode 100644 test/message/source_map_throw_set_immediate.out diff --git a/test/fixtures/source-map/output/source_map_enclosing_function.js b/test/fixtures/source-map/output/source_map_enclosing_function.js new file mode 100644 index 00000000000000..37d2b4ddb04746 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_enclosing_function.js @@ -0,0 +1,7 @@ +// Flags: --enable-source-maps + +'use strict'; +require('../../../common'); +Error.stackTraceLimit = 5; + +require('../enclosing-call-site-min.js'); diff --git a/test/message/source_map_enclosing_function.out b/test/fixtures/source-map/output/source_map_enclosing_function.snapshot similarity index 99% rename from test/message/source_map_enclosing_function.out rename to test/fixtures/source-map/output/source_map_enclosing_function.snapshot index 5bb920e7eba42a..976cd4fdbbc6e9 100644 --- a/test/message/source_map_enclosing_function.out +++ b/test/fixtures/source-map/output/source_map_enclosing_function.snapshot @@ -2,6 +2,7 @@ throw err ^ + Error: an error! at functionD (*enclosing-call-site.js:16:17) at functionC (*enclosing-call-site.js:10:3) diff --git a/test/message/source_map_reference_error_tabs.js b/test/fixtures/source-map/output/source_map_reference_error_tabs.js similarity index 53% rename from test/message/source_map_reference_error_tabs.js rename to test/fixtures/source-map/output/source_map_reference_error_tabs.js index fbe058a5f531bf..59d9f1557adae5 100644 --- a/test/message/source_map_reference_error_tabs.js +++ b/test/fixtures/source-map/output/source_map_reference_error_tabs.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../../common'); Error.stackTraceLimit = 2; -require('../fixtures/source-map/tabs.js'); +require('../tabs.js'); diff --git a/test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot b/test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot new file mode 100644 index 00000000000000..97d02f176c0cb7 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot @@ -0,0 +1,10 @@ +*tabs.coffee:26 + alert "I knew it!" + ^ + + +ReferenceError: alert is not defined + at Object. (*tabs.coffee:26:2) + at Object. (*tabs.coffee:1:14) + +Node.js * diff --git a/test/message/source_map_sourcemapping_url_string.js b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.js similarity index 61% rename from test/message/source_map_sourcemapping_url_string.js rename to test/fixtures/source-map/output/source_map_sourcemapping_url_string.js index 254d18bd080e53..8dca7a35bfe7b9 100644 --- a/test/message/source_map_sourcemapping_url_string.js +++ b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.js @@ -1,11 +1,11 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../../common'); Error.stackTraceLimit = 2; try { - require('../fixtures/source-map/typescript-sourcemapping_url_string'); + require('../typescript-sourcemapping_url_string'); } catch (err) { setTimeout(() => { console.info(err); diff --git a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot new file mode 100644 index 00000000000000..2c1e11eeb9eab1 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot @@ -0,0 +1,3 @@ +Error: an exception. + at Object. (*typescript-sourcemapping_url_string.ts:3:7) + at Module._compile (node:internal*modules*cjs*loader:1241:14) diff --git a/test/message/source_map_throw_catch.js b/test/fixtures/source-map/output/source_map_throw_catch.js similarity index 66% rename from test/message/source_map_throw_catch.js rename to test/fixtures/source-map/output/source_map_throw_catch.js index 603fa81867bcbe..c49ffcff865907 100644 --- a/test/message/source_map_throw_catch.js +++ b/test/fixtures/source-map/output/source_map_throw_catch.js @@ -1,11 +1,11 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../../common'); Error.stackTraceLimit = 2; try { - require('../fixtures/source-map/typescript-throw'); + require('../typescript-throw'); } catch (err) { setTimeout(() => { console.info(err); diff --git a/test/fixtures/source-map/output/source_map_throw_catch.snapshot b/test/fixtures/source-map/output/source_map_throw_catch.snapshot new file mode 100644 index 00000000000000..5eaffbfbf7874f --- /dev/null +++ b/test/fixtures/source-map/output/source_map_throw_catch.snapshot @@ -0,0 +1,4 @@ +reachable +Error: an exception + at branch (*typescript-throw.ts:18:11) + at Object. (*typescript-throw.ts:24:1) diff --git a/test/message/source_map_throw_icu.js b/test/fixtures/source-map/output/source_map_throw_icu.js similarity index 54% rename from test/message/source_map_throw_icu.js rename to test/fixtures/source-map/output/source_map_throw_icu.js index 672c1575c6547a..e80c3d1e308b01 100644 --- a/test/message/source_map_throw_icu.js +++ b/test/fixtures/source-map/output/source_map_throw_icu.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../../common'); Error.stackTraceLimit = 2; -require('../fixtures/source-map/icu'); +require('../icu'); diff --git a/test/fixtures/source-map/output/source_map_throw_icu.snapshot b/test/fixtures/source-map/output/source_map_throw_icu.snapshot new file mode 100644 index 00000000000000..425495062e6423 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_throw_icu.snapshot @@ -0,0 +1,10 @@ +*icu.jsx:3 + ("あ 🐕 🐕", throw Error("an error")); + ^ + + +Error: an error + at Object.createElement (*icu.jsx:3:23) + at Object. (*icu.jsx:9:5) + +Node.js * diff --git a/test/fixtures/source-map/output/source_map_throw_set_immediate.js b/test/fixtures/source-map/output/source_map_throw_set_immediate.js new file mode 100644 index 00000000000000..c5601d61ac5997 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_throw_set_immediate.js @@ -0,0 +1,5 @@ +// Flags: --enable-source-maps + +'use strict'; +require('../../../common'); +require('../uglify-throw'); diff --git a/test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot b/test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot new file mode 100644 index 00000000000000..e5054d01b8f91b --- /dev/null +++ b/test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot @@ -0,0 +1,11 @@ +*uglify-throw-original.js:5 + throw Error('goodbye'); + ^ + + +Error: goodbye + at Hello (*uglify-throw-original.js:5:9) + at Immediate. (*uglify-throw-original.js:9:3) + at process.processImmediate (node:internal*timers:478:21) + +Node.js * diff --git a/test/message/source_map_enclosing_function.js b/test/message/source_map_enclosing_function.js deleted file mode 100644 index f77bd818f02d78..00000000000000 --- a/test/message/source_map_enclosing_function.js +++ /dev/null @@ -1,7 +0,0 @@ -// Flags: --enable-source-maps - -'use strict'; -require('../common'); -Error.stackTraceLimit = 5; - -require('../fixtures/source-map/enclosing-call-site-min.js'); diff --git a/test/message/source_map_reference_error_tabs.out b/test/message/source_map_reference_error_tabs.out deleted file mode 100644 index 7bf2d13305ef12..00000000000000 --- a/test/message/source_map_reference_error_tabs.out +++ /dev/null @@ -1,9 +0,0 @@ -*tabs.coffee:26 - alert "I knew it!" - ^ - -ReferenceError: alert is not defined - at *tabs.coffee:26:2* - at *tabs.coffee:1:14* - -Node.js * diff --git a/test/message/source_map_sourcemapping_url_string.out b/test/message/source_map_sourcemapping_url_string.out deleted file mode 100644 index 3d0b6e15eb6c7a..00000000000000 --- a/test/message/source_map_sourcemapping_url_string.out +++ /dev/null @@ -1,3 +0,0 @@ -Error: an exception. - at *typescript-sourcemapping_url_string.ts:3:7* - at Module._compile (node:internal/modules/cjs/loader:*) diff --git a/test/message/source_map_throw_catch.out b/test/message/source_map_throw_catch.out deleted file mode 100644 index 662d4b5bee4dab..00000000000000 --- a/test/message/source_map_throw_catch.out +++ /dev/null @@ -1,4 +0,0 @@ -reachable -Error: an exception - at *typescript-throw.ts:18:11* - at *typescript-throw.ts:24:1* diff --git a/test/message/source_map_throw_icu.out b/test/message/source_map_throw_icu.out deleted file mode 100644 index 65297956f92437..00000000000000 --- a/test/message/source_map_throw_icu.out +++ /dev/null @@ -1,9 +0,0 @@ -*icu.jsx:3 - ("********", throw Error("an error")); - ^ - -Error: an error - at *icu.jsx:3:23* - at *icu.jsx:9:5* - -Node.js * diff --git a/test/message/source_map_throw_set_immediate.js b/test/message/source_map_throw_set_immediate.js deleted file mode 100644 index 17da1bd7acea66..00000000000000 --- a/test/message/source_map_throw_set_immediate.js +++ /dev/null @@ -1,5 +0,0 @@ -// Flags: --enable-source-maps - -'use strict'; -require('../common'); -require('../fixtures/source-map/uglify-throw'); diff --git a/test/message/source_map_throw_set_immediate.out b/test/message/source_map_throw_set_immediate.out deleted file mode 100644 index 21ce9c8158e016..00000000000000 --- a/test/message/source_map_throw_set_immediate.out +++ /dev/null @@ -1,10 +0,0 @@ -*uglify-throw-original.js:5 - throw Error('goodbye'); - ^ - -Error: goodbye - at Hello *uglify-throw-original.js:5:9* - at *uglify-throw-original.js:9:3* - at process.processImmediate (node:internal/timers:*) - -Node.js * diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 8e43947ab2188f..2043fa57f06a8d 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -30,9 +30,15 @@ describe('sourcemaps output', { concurrency: true }, () => { const tests = [ { name: 'source-map/output/source_map_disabled_by_api.js' }, { name: 'source-map/output/source_map_enabled_by_api.js' }, + { name: 'source-map/output/source_map_enclosing_function.js' }, { name: 'source-map/output/source_map_eval.js' }, { name: 'source-map/output/source_map_no_source_file.js' }, + { name: 'source-map/output/source_map_reference_error_tabs.js' }, + { name: 'source-map/output/source_map_sourcemapping_url_string.js' }, + { name: 'source-map/output/source_map_throw_catch.js' }, { name: 'source-map/output/source_map_throw_first_tick.js' }, + { name: 'source-map/output/source_map_throw_icu.js' }, + { name: 'source-map/output/source_map_throw_set_immediate.js' }, ]; for (const { name, transform } of tests) { it(name, async () => {