Skip to content

Commit

Permalink
chore: migrate test hot (#6341)
Browse files Browse the repository at this point in the history
chore: migrate hot test cases
  • Loading branch information
LingyuCoder authored Apr 24, 2024
1 parent f43bd57 commit 43fedad
Show file tree
Hide file tree
Showing 468 changed files with 56 additions and 450 deletions.
5 changes: 4 additions & 1 deletion packages/rspack-test-tools/jest.config.compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports = {
"<rootDir>/tests/Stats.unittest.js",
"<rootDir>/tests/TreeShaking.test.js",
"<rootDir>/tests/ConfigTestCases.basictest.js",
"<rootDir>/tests/TestCasesNormal.basictest.js"
"<rootDir>/tests/TestCasesNormal.basictest.js",
"<rootDir>/tests/HotTestCasesWeb.test.js",
"<rootDir>/tests/HotTestCasesNode.test.js",
"<rootDir>/tests/HotTestCasesWebWorker.test.js"
]
};
3 changes: 3 additions & 0 deletions packages/rspack-test-tools/jest.config.legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = {
"HotTestStepWeb.test.js",
"ConfigTestCases.basictest.js",
"TestCasesNormal.basictest.js",
"HotTestCasesWeb.test.js",
"HotTestCasesWebWorker.test.js",
"HotTestCasesNode.test.js",
".difftest.js"
]
};
15 changes: 15 additions & 0 deletions packages/rspack-test-tools/src/helper/legacy/supportsWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @ts-nocheck
const nodeVersion = process.versions.node.split(".").map(Number);

module.exports = function supportsWorker() {
// Verify that in the current node version new Worker() accepts URL as the first parameter:
// https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options
if (nodeVersion[0] >= 14) {
return true;
} else if (nodeVersion[0] === 13 && nodeVersion[1] >= 12) {
return true;
} else if (nodeVersion[0] === 12 && nodeVersion[1] >= 17) {
return true;
}
return false;
};
24 changes: 24 additions & 0 deletions packages/rspack-test-tools/src/helper/util/expectWarningFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-nocheck
module.exports = () => {
let warnings = [];
let oldWarn;

beforeEach(done => {
oldWarn = console.warn;
console.warn = m => warnings.push(m);
done();
});

afterEach(done => {
expectWarning();
console.warn = oldWarn;
done();
});

const expectWarning = (...regexp) => {
expect(warnings).toEqual(regexp.map(r => expect.stringMatching(r)));
warnings.length = 0;
};

return expectWarning;
};
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/tests/HotTestCasesNode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const path = require("path");
const { describeByWalk, createHotCase } = require("..");

const NAME = "HotTestCases";
const caseDir = path.resolve(__dirname, "../../rspack/tests/hotCases");
const distDir = path.resolve(__dirname, `../../rspack/tests/js/hot-cases-node`);
const caseDir = path.resolve(__dirname, "./hotCases");
const distDir = path.resolve(__dirname, `./js/hot-cases-node`);

describeByWalk(NAME, caseDir, distDir, (name, src, dist) => {
createHotCase(name, src, dist, "async-node");
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/tests/HotTestCasesWeb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const path = require("path");
const { describeByWalk, createHotCase } = require("..");

const NAME = "HotTestCases";
const caseDir = path.resolve(__dirname, "../../rspack/tests/hotCases");
const distDir = path.resolve(__dirname, `../../rspack/tests/js/hot-cases-web`);
const caseDir = path.resolve(__dirname, "./hotCases");
const distDir = path.resolve(__dirname, `./js/hot-cases-web`);

describeByWalk(NAME, caseDir, distDir, (name, src, dist) => {
createHotCase(name, src, dist, "web");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ const path = require("path");
const { describeByWalk, createHotCase } = require("..");

const NAME = "HotTestCases";
const caseDir = path.resolve(__dirname, "../../rspack/tests/hotCases");
const distDir = path.resolve(
__dirname,
`../../rspack/tests/js/hot-cases-worker`
);
const caseDir = path.resolve(__dirname, "./hotCases");
const distDir = path.resolve(__dirname, `./js/hot-cases-worker`);

describeByWalk(NAME, caseDir, distDir, (name, src, dist) => {
createHotCase(name, src, dist, "webworker");
Expand Down
7 changes: 2 additions & 5 deletions packages/rspack-test-tools/tests/HotTestStepWeb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ const path = require("path");
const { describeByWalk, createHotStepCase } = require("../dist");

const NAME = "HotStepTestCasesNode";
const caseDir = path.resolve(__dirname, "../../rspack/tests/hotCases");
const distDir = path.resolve(
__dirname,
`../../rspack/tests/js/hot-step-cases-web`
);
const caseDir = path.resolve(__dirname, "./hotCases");
const distDir = path.resolve(__dirname, `./js/hot-step-cases-web`);

process.env["RSPACK_HOT_TEST"] = "true";

Expand Down
Loading

2 comments on commit 43fedad

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-04-24 332b127) Current Change
10000_development-mode + exec 2.66 s ± 28 ms 2.71 s ± 38 ms +1.76 %
10000_development-mode_hmr + exec 682 ms ± 3.7 ms 698 ms ± 19 ms +2.42 %
10000_production-mode + exec 2.46 s ± 31 ms 2.58 s ± 61 ms +4.74 %
arco-pro_development-mode + exec 2.48 s ± 86 ms 2.51 s ± 57 ms +1.20 %
arco-pro_development-mode_hmr + exec 429 ms ± 1.2 ms 432 ms ± 5.2 ms +0.69 %
arco-pro_development-mode_hmr_intercept-plugin + exec 441 ms ± 5.4 ms 443 ms ± 5.2 ms +0.59 %
arco-pro_development-mode_intercept-plugin + exec 3.22 s ± 88 ms 3.23 s ± 52 ms +0.45 %
arco-pro_production-mode + exec 3.95 s ± 74 ms 4.05 s ± 72 ms +2.66 %
arco-pro_production-mode_intercept-plugin + exec 4.66 s ± 238 ms 4.92 s ± 104 ms +5.47 %
threejs_development-mode_10x + exec 2.05 s ± 16 ms 2.08 s ± 18 ms +0.99 %
threejs_development-mode_10x_hmr + exec 753 ms ± 13 ms 766 ms ± 11 ms +1.73 %
threejs_production-mode_10x + exec 5.14 s ± 40 ms 5.32 s ± 46 ms +3.57 %

Threshold exceeded: ["arco-pro_production-mode_intercept-plugin + exec"]

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs, self-hosted, Linux, ci ❌ failure
_selftest, ubuntu-latest ✅ success
nx, ubuntu-latest ✅ success
rspress, ubuntu-latest ✅ success
rsbuild, ubuntu-latest ✅ success
compat, ubuntu-latest ✅ success
examples, ubuntu-latest ✅ success

Please sign in to comment.