Skip to content

Commit 8ff03a9

Browse files
JounQinarcanis
andauthored
test: add a new test case for global cache (#10)
* chore: reproduce global cache issue * Fixes relative drive paths * Removes debug * Fixes tidbits * Removes debug * Fixes mistakes * Attempts to support UNC paths * Merge conflict --------- Co-authored-by: Maël Nison <[email protected]>
1 parent 3a51bee commit 8ff03a9

File tree

12 files changed

+309
-26
lines changed

12 files changed

+309
-26
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,24 @@ jobs:
2222
with:
2323
save-cache: ${{ github.ref_name == 'main' }}
2424

25-
- run: cargo check
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: lts/*
28+
29+
- name: Prepare fixtures
30+
run: |
31+
corepack enable
32+
cd fixtures/global-cache
33+
yarn install
34+
35+
- name: Build
36+
run: cargo build
37+
38+
- name: Check
39+
run: cargo check
2640

27-
- run: cargo test
41+
- name: Run tests
42+
run: cargo test
2843

2944
clippy:
3045
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
target
1+
target

Cargo.lock

Lines changed: 63 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ repository = "https://github.com/yarnpkg/pnp-rs"
99

1010
[dependencies]
1111
byteorder = "1"
12-
clean-path = "0.2.1"
1312
concurrent_lru = "^0.2"
1413
fancy-regex = { version = "^0.16.0", default-features = false, features = ["std"] }
1514
miniz_oxide = "^0.8"
1615
mmap-rs = { version = "^0.6", optional = true }
17-
path-slash = "0.2.1"
1816
pathdiff = "^0.2"
1917
radix_trie = "0.2.1"
2018
serde = { version = "1", features = ["derive"] }
2119
serde_json = "1"
2220
thiserror = "2"
2321
rustc-hash = "2"
22+
dirs = "6.0.0"
2423

2524
[dev-dependencies]
2625
rstest = "0.26.0"

fixtures/global-cache/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.yarn/*
2+
.pnp.*

fixtures/global-cache/.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enableGlobalCache: true
2+
3+
nodeLinker: pnp

fixtures/global-cache/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "global-cache",
3+
"dependencies": {
4+
"source-map-support": "^0.5.21"
5+
},
6+
"packageManager": "[email protected]"
7+
}

fixtures/global-cache/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(require.resolve('source-map-support'));

fixtures/global-cache/yarn.lock

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"buffer-from@npm:^1.0.0":
9+
version: 1.1.2
10+
resolution: "buffer-from@npm:1.1.2"
11+
checksum: 10c0/124fff9d66d691a86d3b062eff4663fe437a9d9ee4b47b1b9e97f5a5d14f6d5399345db80f796827be7c95e70a8e765dd404b7c3ff3b3324f98e9b0c8826cc34
12+
languageName: node
13+
linkType: hard
14+
15+
"global-cache@workspace:.":
16+
version: 0.0.0-use.local
17+
resolution: "global-cache@workspace:."
18+
dependencies:
19+
source-map-support: "npm:^0.5.21"
20+
languageName: unknown
21+
linkType: soft
22+
23+
"source-map-support@npm:^0.5.21":
24+
version: 0.5.21
25+
resolution: "source-map-support@npm:0.5.21"
26+
dependencies:
27+
buffer-from: "npm:^1.0.0"
28+
source-map: "npm:^0.6.0"
29+
checksum: 10c0/9ee09942f415e0f721d6daad3917ec1516af746a8120bba7bb56278707a37f1eb8642bde456e98454b8a885023af81a16e646869975f06afc1a711fb90484e7d
30+
languageName: node
31+
linkType: hard
32+
33+
"source-map@npm:^0.6.0":
34+
version: 0.6.1
35+
resolution: "source-map@npm:0.6.1"
36+
checksum: 10c0/ab55398007c5e5532957cb0beee2368529618ac0ab372d789806f5718123cc4367d57de3904b4e6a4170eb5a0b0f41373066d02ca0735a0c4d75c7d328d3e011
37+
languageName: node
38+
linkType: hard

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ pub fn init_pnp_manifest(manifest: &mut Manifest, p: &Path) {
161161
for (name, ranges) in manifest.package_registry_data.iter_mut() {
162162
for (reference, info) in ranges.iter_mut() {
163163
let package_location = manifest.manifest_dir.join(info.package_location.clone());
164-
165164
let normalized_location = util::normalize_path(package_location.to_string_lossy());
166165

167166
info.package_location = PathBuf::from(normalized_location);
@@ -208,6 +207,8 @@ pub fn find_locator<'a>(manifest: &'a Manifest, path: &Path) -> Option<&'a Packa
208207
}
209208
}
210209

210+
let path = util::normalize_path(path.to_string_lossy());
211+
211212
manifest.location_trie.get_ancestor_value(&path)
212213
}
213214

0 commit comments

Comments
 (0)