Skip to content

Commit 1d7b488

Browse files
authored
test: split Config, Watch and NativeWatcher tests into 3 parts for better parallelization (#12379)
This commit splits the following test files into 3 parts each: - Config.test.js → Config.part1/2/3.test.js (136 dirs: 49/44/43) - Watch.test.js → Watch.part1/2/3.test.js (32 dirs: 12/9/11) - NativeWatcher.test.js → NativeWatcher.part1/2/3.test.js (32 dirs: 12/9/11) The split is based on alphabetical ranges for easy maintenance: - Part 1: a-d (or a-co for Watch/NativeWatcher) - Part 2: e-o (or cp-p for Watch/NativeWatcher) - Part 3: p-z (or r-z for Watch/NativeWatcher) Benefits: - Better parallelization across test workers - More balanced load distribution - Easy to maintain with simple regex patterns 🤖 This PR was generated by AI (Cursor/Claude)
1 parent 3faa835 commit 1d7b488

File tree

12 files changed

+168
-14
lines changed

12 files changed

+168
-14
lines changed

packages/rspack-test-tools/src/helper/directory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function describeByWalk(
2424
const describeFn = options.describe || describe;
2525
const testBasename = path
2626
.basename(testFile)
27-
.replace(/\.(diff|hot)?test\.(j|t)s/, "");
27+
.replace(/(\.part\d+)?\.(diff|hot)?test\.(j|t)s/, "");
2828
const testId = testBasename.charAt(0).toLowerCase() + testBasename.slice(1);
2929
const sourceBase =
3030
options.source || path.join(path.dirname(testFile), `${testId}Cases`);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const path = require("path");
2+
const { describeByWalk, createConfigCase } = require("@rspack/test-tools");
3+
4+
// Part 1: Test cases starting with a-d (49 dirs, 36.0%)
5+
describeByWalk(
6+
__filename,
7+
(name, src, dist) => {
8+
createConfigCase(name, src, dist);
9+
},
10+
{
11+
source: require("path").join(__dirname, "configCases"),
12+
dist: path.resolve(__dirname, `./js/config`),
13+
exclude: [
14+
// Exclude e-z and non-ascii
15+
/^[e-z]/,
16+
/^[^a-d]/
17+
]
18+
}
19+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const path = require("path");
2+
const { describeByWalk, createConfigCase } = require("@rspack/test-tools");
3+
4+
// Part 2: Test cases starting with e-o (43 dirs, 31.6%)
5+
describeByWalk(
6+
__filename,
7+
(name, src, dist) => {
8+
createConfigCase(name, src, dist);
9+
},
10+
{
11+
source: require("path").join(__dirname, "configCases"),
12+
dist: path.resolve(__dirname, `./js/config`),
13+
exclude: [
14+
// Exclude a-d
15+
/^[a-d]/,
16+
// Exclude p-z and non-ascii
17+
/^[p-z]/,
18+
/^[^a-o]/
19+
]
20+
}
21+
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require("path");
2+
const { describeByWalk, createConfigCase } = require("@rspack/test-tools");
3+
4+
// Part 3: Test cases starting with p-z and others (44 dirs, 32.4%)
5+
describeByWalk(
6+
__filename,
7+
(name, src, dist) => {
8+
createConfigCase(name, src, dist);
9+
},
10+
{
11+
source: require("path").join(__dirname, "configCases"),
12+
dist: path.resolve(__dirname, `./js/config`),
13+
exclude: [
14+
// Exclude a-o
15+
/^[a-o]/
16+
]
17+
}
18+
);

tests/rspack-test/Config.test.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const path = require("path");
2+
const { describeByWalk, createNativeWatcher } = require("@rspack/test-tools");
3+
const tempDir = path.resolve(__dirname, `./js/temp`);
4+
5+
// Part 1: Test cases starting with a-co (12 dirs, 37.5%)
6+
describeByWalk(
7+
__filename,
8+
(name, src, dist) => {
9+
createNativeWatcher(name, src, dist, path.join(tempDir, name));
10+
},
11+
{
12+
source: path.join(__dirname, `./watchCases`),
13+
dist: path.resolve(__dirname, `./js/native-watcher/watch`),
14+
exclude: [
15+
// Exclude cp-z
16+
/^c[p-z]/,
17+
/^[d-z]/
18+
]
19+
}
20+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require("path");
2+
const { describeByWalk, createNativeWatcher } = require("@rspack/test-tools");
3+
const tempDir = path.resolve(__dirname, `./js/temp`);
4+
5+
// Part 2: Test cases starting with cp-p (9 dirs, 28.1%)
6+
describeByWalk(
7+
__filename,
8+
(name, src, dist) => {
9+
createNativeWatcher(name, src, dist, path.join(tempDir, name));
10+
},
11+
{
12+
source: path.join(__dirname, `./watchCases`),
13+
dist: path.resolve(__dirname, `./js/native-watcher/watch`),
14+
exclude: [
15+
// Exclude a-co
16+
/^[a-c][a-o]/,
17+
/^[ab]/,
18+
// Exclude r-z
19+
/^[r-z]/
20+
]
21+
}
22+
);

tests/rspack-test/NativeWatcher.test.js renamed to tests/rspack-test/NativeWatcher.part3.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ const path = require("path");
22
const { describeByWalk, createNativeWatcher } = require("@rspack/test-tools");
33
const tempDir = path.resolve(__dirname, `./js/temp`);
44

5+
// Part 3: Test cases starting with r-z (11 dirs, 34.4%)
56
describeByWalk(
67
__filename,
78
(name, src, dist) => {
89
createNativeWatcher(name, src, dist, path.join(tempDir, name));
910
},
1011
{
1112
source: path.join(__dirname, `./watchCases`),
12-
dist: path.resolve(__dirname, `./js/native-watcher/watch`)
13+
dist: path.resolve(__dirname, `./js/native-watcher/watch`),
14+
exclude: [
15+
// Exclude a-p
16+
/^[a-p]/
17+
]
1318
}
1419
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const path = require("path");
2+
const { describeByWalk, createWatchCase } = require("@rspack/test-tools");
3+
const tempDir = path.resolve(__dirname, `./js/temp`);
4+
5+
// Part 1: Test cases starting with a-co (12 dirs, 37.5%)
6+
describeByWalk(
7+
__filename,
8+
(name, src, dist) => {
9+
createWatchCase(name, src, dist, path.join(tempDir, name));
10+
},
11+
{
12+
source: require("path").join(__dirname, "watchCases"),
13+
dist: path.resolve(__dirname, `./js/watch`),
14+
exclude: [
15+
// Exclude cp-z
16+
/^c[p-z]/,
17+
/^[d-z]/
18+
]
19+
}
20+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require("path");
2+
const { describeByWalk, createWatchCase } = require("@rspack/test-tools");
3+
const tempDir = path.resolve(__dirname, `./js/temp`);
4+
5+
// Part 2: Test cases starting with cp-p (9 dirs, 28.1%)
6+
describeByWalk(
7+
__filename,
8+
(name, src, dist) => {
9+
createWatchCase(name, src, dist, path.join(tempDir, name));
10+
},
11+
{
12+
source: require("path").join(__dirname, "watchCases"),
13+
dist: path.resolve(__dirname, `./js/watch`),
14+
exclude: [
15+
// Exclude a-co
16+
/^[a-c][a-o]/,
17+
/^[ab]/,
18+
// Exclude r-z
19+
/^[r-z]/
20+
]
21+
}
22+
);

0 commit comments

Comments
 (0)