Skip to content

Commit e827f37

Browse files
committed
add a test
1 parent 4002105 commit e827f37

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default 0;
2+
---
3+
export default 1;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import value from "./driver";
2+
import version from "./tool"
3+
4+
it("should invalidate work when symlink changes", async () => {
5+
if (COMPILER_INDEX == 0) {
6+
expect(version).toBe(100);
7+
await NEXT_START();
8+
}
9+
if (COMPILER_INDEX == 1) {
10+
expect(version).toBe(200);
11+
}
12+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const path = require("path");
2+
const fs = require("fs/promises");
3+
4+
let index = 1
5+
const libPath = path.join(__dirname, "./tool")
6+
/** @type {import("@rspack/core").Configuration} */
7+
module.exports = {
8+
context: __dirname,
9+
experiments: {
10+
cache: {
11+
type: "persistent",
12+
snapshot: {
13+
managedPaths: [path.join(__dirname, "./tool")]
14+
}
15+
}
16+
},
17+
plugins: [
18+
{
19+
apply(compiler) {
20+
compiler.hooks.beforeCompile.tapPromise("Test Plugin", async function () {
21+
try {
22+
await fs.unlink(libPath);
23+
} catch {}
24+
25+
await fs.symlink(libPath + '_' + index, libPath);
26+
27+
index++;
28+
});
29+
}
30+
}
31+
]
32+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 100
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "managed-paths-test-lib",
3+
"version": "0.100.0",
4+
"main": "./file.js"
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 200
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "managed-paths-test-lib",
3+
"version": "0.200.0",
4+
"main": "./file.js"
5+
}

0 commit comments

Comments
 (0)