Skip to content

Commit c33674d

Browse files
test: run the minify corpora as three shard files jest runs in parallel
1 parent 0bd77d3 commit c33674d

10 files changed

Lines changed: 1274 additions & 671 deletions

‎TESTING_DOCS.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Directories come first, in alphabetical order, then the individual files worth t
4040
#### `test262-cases/`
4141

4242
- **Purpose**: ECMAScript test262 conformance test cases.
43-
- **Usage**: Git submodule — initialize with `git submodule update --init test/external/test262-cases`. Test runners: `test/specCases/test262.spectest.js`, which builds and runs each test in development, in production unminified (a failure there is webpack's own, not a minimizer's), and in production once per JavaScript minimizer: terser, and webpack's printer as `experiments.futureDefaults` switches it. The minified modes skip the `fn-name` cases a renamed binding changes and keep function and class names and turn `pure_getters` off, as test262 reads names and properties that throw; the printer also runs with `pure_conversions` and `pure_heritage` off, as test262 converts and extends values that run code or throw on purpose. What each minimizer still fails is listed by reason in its `MINIFIED_FAILURES` table, and a listed case that passes fails the suite until removed. And `test/specCases/minify-corpora.spectest.js`, which minifies each test with webpack's printer and with terser.
43+
- **Usage**: Git submodule — initialize with `git submodule update --init test/external/test262-cases`. Test runners: `test/specCases/test262.spectest.js`, which builds and runs each test in development, in production unminified (a failure there is webpack's own, not a minimizer's), and in production once per JavaScript minimizer: terser, and webpack's printer as `experiments.futureDefaults` switches it. The minified modes skip the `fn-name` cases a renamed binding changes and keep function and class names and turn `pure_getters` off, as test262 reads names and properties that throw; the printer also runs with `pure_conversions` and `pure_heritage` off, as test262 converts and extends values that run code or throw on purpose. What each minimizer still fails is listed by reason in its `MINIFIED_FAILURES` table, and a listed case that passes fails the suite until removed. And `test/specCases/minify-corpora.js`, which minifies each test with webpack's printer and with terser.
4444

4545
#### `html5lib-tests/`
4646

@@ -65,17 +65,17 @@ Directories come first, in alphabetical order, then the individual files worth t
6565
#### `swc/`
6666

6767
- **Purpose**: swc's repository, read only under `crates/swc_ecma_minifier/tests`: its fixtures with their configs, the tests `exec.rs` and `mangle.rs` write inline, and the libraries it measures itself on. Each is held to terser's bytes like the terser corpora; a test with an `expected.stdout`, and every `exec.rs` test, also has its outputs run, and webpack's output may be no bigger than each fixture's recorded `output.js`, nor than what swc's port of a terser case records when its `passing.txt` lists it, unless `SWC_SMALLER` lists why.
68-
- **Usage**: Git submodule — initialize with `git submodule update --init --depth 1 test/external/swc`. Test runner: `test/specCases/minify-corpora.spectest.js` (`yarn test:minify-corpora`).
68+
- **Usage**: Git submodule — initialize with `git submodule update --init --depth 1 test/external/swc`. Test runner: `test/specCases/minify-corpora.js` (`yarn test:minify-corpora`).
6969

7070
#### `oxc/`
7171

7272
- **Purpose**: oxc's repository, pinned to the commit that released webpack's `oxc-minify` devDependency and read only under `crates/oxc_minifier/tests`: the source each `test…(` helper call in its Rust tests passes first, but TypeScript. Each is held to terser's bytes like the other corpora, and under the default minimizer's options every source of every corpus but test262 is also minified by `oxc-minify`: webpack's output may be no bigger than oxc's unless `OXC_SMALLER` lists why, and an oxc output that misprints is no lead.
73-
- **Usage**: Git submodule — initialize with `git submodule update --init --depth 1 test/external/oxc`. Test runner: `test/specCases/minify-corpora.spectest.js` (`yarn test:minify-corpora`), which also fails when the pin and the installed `oxc-minify` disagree.
73+
- **Usage**: Git submodule — initialize with `git submodule update --init --depth 1 test/external/oxc`. Test runner: `test/specCases/minify-corpora.js` (`yarn test:minify-corpora`), which also fails when the pin and the installed `oxc-minify` disagree.
7474

7575
#### `terser/`
7676

7777
- **Purpose**: terser's own repository, pinned to webpack's `terser` devDependency. Its `test/compress` cases and `test/input` files are two of the seven corpora `lib/javascript/syntax-printer.js` is held to (test262, swc's fixtures, `exec.rs` and `mangle.rs` tests, and oxc's tests are the other five): each source is minified by terser as published and by webpack's printer under several option sets, and the outputs, or the errors, must be byte-for-byte the same, but for what webpack's `correct` phase fixes. A case stating its `expect_stdout` also has each output run in terser's sandbox, which must print it — or, for `expect_stdout: true`, do whatever its input does, a throw or silence included.
78-
- **Usage**: Git submodule — initialize with `git submodule update --init --depth 1 test/external/terser`. Test runner: `test/specCases/minify-corpora.spectest.js` (`yarn test:minify-corpora`), which also fails when the pin and the installed `terser` disagree, so bumping the dependency means moving the pin with it. A new corpus is one entry in its `CORPORA` list.
78+
- **Usage**: Git submodule — initialize with `git submodule update --init --depth 1 test/external/terser`. Test runner: `test/specCases/minify-corpora.js` (`yarn test:minify-corpora`), which also fails when the pin and the installed `terser` disagree, so bumping the dependency means moving the pin with it. A new corpus is one entry in its `CORPORA` list.
7979

8080
### `fixtures/`
8181

@@ -118,7 +118,7 @@ Directories come first, in alphabetical order, then the individual files worth t
118118
- `syntaxEquivalence.spectest.js` — `yarn test:syntax-equivalence`
119119
- `cssParsing-webpack.spectest.js` — `yarn test:css-parsing`
120120
- `xmlconf.spectest.js` — `yarn test:xmlconf`
121-
- `minify-corpora.spectest.js` — `yarn test:minify-corpora`
121+
- `minify-corpora-{1,2,3}.spectest.js` — `yarn test:minify-corpora`: the suite in `test/specCases/minify-corpora.js`, its corpus groups dealt to three files by size so jest runs them in parallel; the last to finish checks no table entry went unmet
122122
- `js-fuzz.spectest.js` — `yarn test:js-fuzz`: programs from `test/helpers/jsFuzzProgram.js`, in the sloppy ES5 terser's ufuzz writes, in modern syntax, as modules importing a fixed `dep` and as webpack-shaped bundles, minified under ufuzz's option sets, webpack's and random ones; the parser is held to acorn's tree on each program and output, the printer to the tree it read and to its own output, each output to what its program prints and exports, the default set's source map to its output and source, and the output to what it prints minified again. Needs no submodule; `JS_FUZZ_SEED=<n>` replays one seed, `JS_FUZZ_SEED=random` runs a new one named in the test's title, and `JS_FUZZ_PROGRAMS` sets the programs per seed.
123123

124124
### `statsCases/`

‎cspell.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@
638638
"yarn.lock",
639639
"**/package-lock.json",
640640
"tooling/deep-webpack-imports.json",
641+
"test/specCases/minify-corpora-timings.json",
641642
"tooling/comparison/css-tool-comparison/stylesheets.json",
642643
"types.d.ts",
643644
"**/**/*.snap",

‎docs/syntax.md‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎eslint.config.mjs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ export default defineConfig([
311311
}
312312
}
313313
},
314+
{
315+
// The suite its three `minify-corpora-*.spectest.js` shards each define.
316+
files: ["test/specCases/minify-corpora.js"],
317+
rules: {
318+
"jest/no-export": "off"
319+
}
320+
},
314321
{
315322
files: ["test/helpers/**/*.{js,cjs,mjs}"],
316323
languageOptions: {

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"test:integration:b": "yarn test:base --testMatch \"<rootDir>/test/*.longtest.js\"",
9090
"test:test262": "yarn test:base --testMatch \"<rootDir>/test/specCases/test262.spectest.js\"",
9191
"test:test262-parser": "yarn test:base --testMatch \"<rootDir>/test/specCases/test262-parser.spectest.js\"",
92-
"test:minify-corpora": "yarn test:base --testMatch \"<rootDir>/test/specCases/minify-corpora.spectest.js\"",
92+
"test:minify-corpora": "yarn test:base --testMatch \"<rootDir>/test/specCases/minify-corpora-*.spectest.js\"",
9393
"test:js-fuzz": "yarn test:base --testMatch \"<rootDir>/test/specCases/js-fuzz.spectest.js\"",
9494
"test:html5lib": "yarn test:base --testMatch \"<rootDir>/test/specCases/html5lib.spectest.js\"",
9595
"test:syntax-equivalence": "yarn test:base --testMatch \"<rootDir>/test/specCases/syntaxEquivalence.spectest.js\"",
@@ -118,7 +118,7 @@
118118
"cover:html5lib": "yarn cover:base --testMatch \"<rootDir>/test/specCases/html5lib.spectest.js\" --coverage",
119119
"cover:syntax-equivalence": "yarn cover:base --testMatch \"<rootDir>/test/specCases/syntaxEquivalence.spectest.js\" --coverage",
120120
"cover:css-parsing": "yarn cover:base --testMatch \"<rootDir>/test/specCases/cssParsing-webpack.spectest.js\" --coverage",
121-
"cover:minify": "yarn cover:base --testMatch \"<rootDir>/test/specCases/minify-corpora.spectest.js\" --coverage",
121+
"cover:minify": "yarn cover:base --testMatch \"<rootDir>/test/specCases/minify-corpora-*.spectest.js\" --coverage",
122122
"cover:minify-fuzz": "yarn cover:base --testMatch \"<rootDir>/test/specCases/js-fuzz.spectest.js\" --coverage",
123123
"cover:test262-parser": "yarn cover:base --testMatch \"<rootDir>/test/specCases/test262-parser.spectest.js\" --coverage",
124124
"cover:xmlconf": "yarn cover:base --testMatch \"<rootDir>/test/specCases/xmlconf.spectest.js\" --coverage",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
require("./minify-corpora")(1, 3);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
require("./minify-corpora")(2, 3);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
require("./minify-corpora")(3, 3);

0 commit comments

Comments
 (0)