Skip to content

Commit 3d5a4ef

Browse files
authored
test: fix broken windows tests (#381)
1 parent 850cbf9 commit 3d5a4ef

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ packages:
22
- 'npm'
33
- 'napi'
44
- 'fixtures/pnpm'
5+
6+
# For `windows_symlinked_longfilename` in tests/resolve_test.rs
7+
virtualStoreDirMaxLength: 1024

tests/resolve_test.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ fn chinese() {
1818
}
1919

2020
#[test]
21-
#[ignore = "failed on windows"]
2221
fn styled_components() {
2322
let dir = dir();
2423
let path = dir.join("fixtures/pnpm");
25-
let module_path = dir.join("node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/styled-components");
24+
let module_path = dir
25+
.join("node_modules")
26+
.join(".pnpm")
27+
28+
.join("node_modules")
29+
.join("styled-components");
2630
let specifier = "styled-components";
2731

2832
// cjs
@@ -31,7 +35,7 @@ fn styled_components() {
3135
let resolution = Resolver::new(options).resolve(&path, specifier);
3236
assert_eq!(
3337
resolution.map(oxc_resolver::Resolution::into_path_buf),
34-
Ok(module_path.join("dist/styled-components.browser.cjs.js"))
38+
Ok(module_path.join("dist").join("styled-components.browser.cjs.js"))
3539
);
3640

3741
// esm
@@ -43,7 +47,7 @@ fn styled_components() {
4347
let resolution = Resolver::new(options).resolve(&path, specifier);
4448
assert_eq!(
4549
resolution.map(oxc_resolver::Resolution::into_path_buf),
46-
Ok(module_path.join("dist/styled-components.browser.esm.js"))
50+
Ok(module_path.join("dist").join("styled-components.browser.esm.js"))
4751
);
4852
}
4953

@@ -207,13 +211,27 @@ fn nested_symlinks() {
207211
);
208212
}
209213

214+
// NOTE: pnpm v10 shortens windows directory path.
215+
// `virtualStoreDirMaxLength: 1024` is set in pnpm-workspace.yaml to keep the long name.
210216
#[test]
211-
#[ignore = "failed on windows"]
212217
fn windows_symlinked_longfilename() {
213218
let dir = dir();
214219
let path = dir.join("fixtures/pnpm");
215-
let module_path = dir.join("node_modules/.pnpm/@oxc-resolver+test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_7a8cf2210bc70feb075991a339017f04/node_modules/@oxc-resolver/test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/index.js");
216-
217-
let resolution = Resolver::new(ResolveOptions::default()).resolve(&path, "@oxc-resolver/test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").map(|r| r.full_path());
220+
let module_path = dir.join("node_modules")
221+
.join(".pnpm")
222+
.join("@oxc-resolver+test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@file+fixtures+pnpm+longfilename")
223+
.join("node_modules")
224+
.join("@oxc-resolver")
225+
.join("test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
226+
.join("index.js");
227+
228+
// Note: dunce::canonicalize seems to only trim \\?\ when the path is shorter than 260 chars.
229+
// Our implementation should mitigate that.
230+
// <https://gitlab.com/kornelski/dunce/-/blob/1ee29a83526c9f4c3618e1335f0454c878a54dcf/src/lib.rs#L176-180>
231+
assert!(module_path.as_os_str().len() > 260, "Windows path must be super long.");
232+
233+
let specifier = "@oxc-resolver/test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
234+
let resolution =
235+
Resolver::new(ResolveOptions::default()).resolve(&path, specifier).map(|r| r.full_path());
218236
assert_eq!(resolution, Ok(module_path));
219237
}

0 commit comments

Comments
 (0)