From 9c2c96ae774d6be7137e2af04657f0924ad80e1e Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 04:21:07 +0200 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 --------- .../message/source_map_sourcemapping_url_string.out | 3 --- graal-nodejs/test/message/source_map_throw_catch.out | 4 ---- graal-nodejs/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 graal-nodejs/test/fixtures/source-map/output/source_map_enclosing_function.js rename graal-nodejs/test/{message/source_map_enclosing_function.out => fixtures/source-map/output/source_map_enclosing_function.snapshot} (99%) rename graal-nodejs/test/{message => fixtures/source-map/output}/source_map_reference_error_tabs.js (53%) create mode 100644 graal-nodejs/test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot rename graal-nodejs/test/{message => fixtures/source-map/output}/source_map_sourcemapping_url_string.js (61%) create mode 100644 graal-nodejs/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot rename graal-nodejs/test/{message => fixtures/source-map/output}/source_map_throw_catch.js (66%) create mode 100644 graal-nodejs/test/fixtures/source-map/output/source_map_throw_catch.snapshot rename graal-nodejs/test/{message => fixtures/source-map/output}/source_map_throw_icu.js (54%) create mode 100644 graal-nodejs/test/fixtures/source-map/output/source_map_throw_icu.snapshot create mode 100644 graal-nodejs/test/fixtures/source-map/output/source_map_throw_set_immediate.js create mode 100644 graal-nodejs/test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot delete mode 100644 graal-nodejs/test/message/source_map_enclosing_function.js delete mode 100644 graal-nodejs/test/message/source_map_reference_error_tabs.out delete mode 100644 graal-nodejs/test/message/source_map_sourcemapping_url_string.out delete mode 100644 graal-nodejs/test/message/source_map_throw_catch.out delete mode 100644 graal-nodejs/test/message/source_map_throw_icu.out delete mode 100644 graal-nodejs/test/message/source_map_throw_set_immediate.js delete mode 100644 graal-nodejs/test/message/source_map_throw_set_immediate.out diff --git a/graal-nodejs/test/fixtures/source-map/output/source_map_enclosing_function.js b/graal-nodejs/test/fixtures/source-map/output/source_map_enclosing_function.js new file mode 100644 index 00000000000..37d2b4ddb04 --- /dev/null +++ b/graal-nodejs/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/graal-nodejs/test/message/source_map_enclosing_function.out b/graal-nodejs/test/fixtures/source-map/output/source_map_enclosing_function.snapshot similarity index 99% rename from graal-nodejs/test/message/source_map_enclosing_function.out rename to graal-nodejs/test/fixtures/source-map/output/source_map_enclosing_function.snapshot index 5bb920e7eba..976cd4fdbbc 100644 --- a/graal-nodejs/test/message/source_map_enclosing_function.out +++ b/graal-nodejs/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/graal-nodejs/test/message/source_map_reference_error_tabs.js b/graal-nodejs/test/fixtures/source-map/output/source_map_reference_error_tabs.js similarity index 53% rename from graal-nodejs/test/message/source_map_reference_error_tabs.js rename to graal-nodejs/test/fixtures/source-map/output/source_map_reference_error_tabs.js index fbe058a5f53..59d9f1557ad 100644 --- a/graal-nodejs/test/message/source_map_reference_error_tabs.js +++ b/graal-nodejs/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/graal-nodejs/test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot b/graal-nodejs/test/fixtures/source-map/output/source_map_reference_error_tabs.snapshot new file mode 100644 index 00000000000..97d02f176c0 --- /dev/null +++ b/graal-nodejs/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/graal-nodejs/test/message/source_map_sourcemapping_url_string.js b/graal-nodejs/test/fixtures/source-map/output/source_map_sourcemapping_url_string.js similarity index 61% rename from graal-nodejs/test/message/source_map_sourcemapping_url_string.js rename to graal-nodejs/test/fixtures/source-map/output/source_map_sourcemapping_url_string.js index 254d18bd080..8dca7a35bfe 100644 --- a/graal-nodejs/test/message/source_map_sourcemapping_url_string.js +++ b/graal-nodejs/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/graal-nodejs/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot b/graal-nodejs/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot new file mode 100644 index 00000000000..6a109c904e1 --- /dev/null +++ b/graal-nodejs/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) + * diff --git a/graal-nodejs/test/message/source_map_throw_catch.js b/graal-nodejs/test/fixtures/source-map/output/source_map_throw_catch.js similarity index 66% rename from graal-nodejs/test/message/source_map_throw_catch.js rename to graal-nodejs/test/fixtures/source-map/output/source_map_throw_catch.js index 603fa81867b..c49ffcff865 100644 --- a/graal-nodejs/test/message/source_map_throw_catch.js +++ b/graal-nodejs/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/graal-nodejs/test/fixtures/source-map/output/source_map_throw_catch.snapshot b/graal-nodejs/test/fixtures/source-map/output/source_map_throw_catch.snapshot new file mode 100644 index 00000000000..5eaffbfbf78 --- /dev/null +++ b/graal-nodejs/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/graal-nodejs/test/message/source_map_throw_icu.js b/graal-nodejs/test/fixtures/source-map/output/source_map_throw_icu.js similarity index 54% rename from graal-nodejs/test/message/source_map_throw_icu.js rename to graal-nodejs/test/fixtures/source-map/output/source_map_throw_icu.js index 672c1575c65..e80c3d1e308 100644 --- a/graal-nodejs/test/message/source_map_throw_icu.js +++ b/graal-nodejs/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/graal-nodejs/test/fixtures/source-map/output/source_map_throw_icu.snapshot b/graal-nodejs/test/fixtures/source-map/output/source_map_throw_icu.snapshot new file mode 100644 index 00000000000..425495062e6 --- /dev/null +++ b/graal-nodejs/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/graal-nodejs/test/fixtures/source-map/output/source_map_throw_set_immediate.js b/graal-nodejs/test/fixtures/source-map/output/source_map_throw_set_immediate.js new file mode 100644 index 00000000000..c5601d61ac5 --- /dev/null +++ b/graal-nodejs/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/graal-nodejs/test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot b/graal-nodejs/test/fixtures/source-map/output/source_map_throw_set_immediate.snapshot new file mode 100644 index 00000000000..86a95127e29 --- /dev/null +++ b/graal-nodejs/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:476:21) + +Node.js * diff --git a/graal-nodejs/test/message/source_map_enclosing_function.js b/graal-nodejs/test/message/source_map_enclosing_function.js deleted file mode 100644 index f77bd818f02..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/message/source_map_reference_error_tabs.out b/graal-nodejs/test/message/source_map_reference_error_tabs.out deleted file mode 100644 index 7bf2d13305e..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/message/source_map_sourcemapping_url_string.out b/graal-nodejs/test/message/source_map_sourcemapping_url_string.out deleted file mode 100644 index 3d0b6e15eb6..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/message/source_map_throw_catch.out b/graal-nodejs/test/message/source_map_throw_catch.out deleted file mode 100644 index 662d4b5bee4..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/message/source_map_throw_icu.out b/graal-nodejs/test/message/source_map_throw_icu.out deleted file mode 100644 index 65297956f92..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/message/source_map_throw_set_immediate.js b/graal-nodejs/test/message/source_map_throw_set_immediate.js deleted file mode 100644 index 17da1bd7ace..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/message/source_map_throw_set_immediate.out b/graal-nodejs/test/message/source_map_throw_set_immediate.out deleted file mode 100644 index 21ce9c8158e..00000000000 --- a/graal-nodejs/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/graal-nodejs/test/parallel/test-node-output-sourcemaps.mjs b/graal-nodejs/test/parallel/test-node-output-sourcemaps.mjs index c53a0598958..b01f30765c7 100644 --- a/graal-nodejs/test/parallel/test-node-output-sourcemaps.mjs +++ b/graal-nodejs/test/parallel/test-node-output-sourcemaps.mjs @@ -28,9 +28,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 () => {