refactor: consolidate fixture directories for better test file mapping

- Move dot/, abnormal-relative-* into fixtures/resolve/ (used by resolve.rs)
- Move global-pnp/ into fixtures/pnp/ (used by pnp.rs)
- Move pnpm-workspace/ into fixtures/pnpm/ (used by napi tests)
- Move bench-tsconfig-paths/ into fixtures/tsconfig/ (used by benches)
- Delete unused fixtures/prefer-file-over-dir/

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
Boshen
2026-03-24 15:32:04 +08:00
co-authored by Hanzo Dev
parent d290e9a841
commit a4604e8d43
41 changed files with 22 additions and 31 deletions
+2 -2
View File
@@ -26,8 +26,8 @@ runs:
cd fixtures/pnp
yarn install
cd ../global-pnp
cd global-pnp
yarn install
cd ../yarn
cd ../../yarn
yarn install
+2 -2
View File
@@ -501,7 +501,7 @@ mod memory_fs {
) -> (Self, PathBuf, PathBuf, Vec<String>) {
let fs = Self::new();
let cwd = std::env::current_dir().unwrap();
let root = cwd.join(format!("fixtures/bench-tsconfig-paths/{alias_count}"));
let root = cwd.join(format!("fixtures/tsconfig/bench-tsconfig-paths/{alias_count}"));
let importer = root.join("app/main.ts");
let tsconfig_path = root.join("tsconfig.json");
assert!(
@@ -533,7 +533,7 @@ mod memory_fs {
// Load fixtures from enhanced-resolve
self.load_directory_tree(&cwd.join("fixtures/enhanced-resolve"));
self.load_directory_tree(&cwd.join("fixtures/bench-tsconfig-paths"));
self.load_directory_tree(&cwd.join("fixtures/tsconfig/bench-tsconfig-paths"));
// Load specific node_modules packages for benchmarks
self.load_node_modules_packages(&cwd);
-1
View File
@@ -1 +0,0 @@
!node_modules
View File
View File
View File
View File
-3
View File
@@ -1,3 +0,0 @@
{
"name": "bar"
}
@@ -1,3 +0,0 @@
{
"name": "prefer-file-over-dir"
}
+1 -1
View File
@@ -19,7 +19,7 @@ init:
install:
pnpm install
cd fixtures/pnp; yarn
cd fixtures/global-pnp; yarn
cd fixtures/pnp/global-pnp; yarn
cd fixtures/yarn; yarn
# When ready, run the same CI commands
+1 -1
View File
@@ -234,7 +234,7 @@ test("resolve pnpm package", () => {
});
test("resolve recursive symbol link", () => {
const workspaceProjectPath = join(fixturesDir, "pnpm-workspace");
const workspaceProjectPath = join(fixturesDir, "pnpm/pnpm-workspace");
const resolver = new ResolverFactory({});
const react = resolver.sync(
+4 -4
View File
@@ -70,22 +70,22 @@ importers:
specifier: 6.1.17
version: 6.1.17([email protected]([email protected]))([email protected])
fixtures/pnpm-workspace:
fixtures/pnpm/pnpm-workspace:
dependencies:
enhanced-resolve:
specifier: ^5.18.2
version: 5.18.3
oxc-resolver:
specifier: workspace:*
version: link:../..
version: link:../../..
fixtures/pnpm-workspace/packages/app:
fixtures/pnpm/pnpm-workspace/packages/app:
dependencies:
'@monorepo/lib':
specifier: workspace:*
version: link:../lib
fixtures/pnpm-workspace/packages/lib:
fixtures/pnpm/pnpm-workspace/packages/lib:
dependencies:
react:
specifier: ^19.1.0
+1 -1
View File
@@ -3,7 +3,7 @@ packages:
- napi
- fixtures/pnpm
- fixtures/tsconfck
- fixtures/pnpm-workspace/**
- fixtures/pnpm/pnpm-workspace/**
catalog:
vite: npm:@voidzero-dev/vite-plus-core@latest
+1 -1
View File
@@ -182,7 +182,7 @@ fn resolve_global_cache() {
#[cfg(not(windows))]
let global_cache = home_dir.join(".yarn/berry/cache");
let fixture = super::fixture_root().join("global-pnp");
let fixture = super::fixture_root().join("pnp/global-pnp");
let resolver = Resolver::new(ResolveOptions {
cwd: Some(fixture),
yarn_pnp: true,
+3 -3
View File
@@ -168,7 +168,7 @@ fn resolve_file_rejects_parentless_path() {
#[test]
fn resolve_dot() {
let f = super::fixture_root().join("dot");
let f = super::fixture_root().join("resolve/dot");
let foo_dir: std::path::PathBuf = f.join("foo");
let resolver = Resolver::default();
let foo_index = foo_dir.join("index.js");
@@ -195,7 +195,7 @@ fn resolve_dot() {
#[test]
fn abnormal_relative() {
let f = super::fixture_root().join("abnormal-relative-with-node_modules");
let f = super::fixture_root().join("resolve/abnormal-relative-with-node_modules");
let base = f.join("foo/bar/baz");
@@ -229,7 +229,7 @@ fn abnormal_relative() {
);
}
let f = super::fixture_root().join("abnormal-relative-without-node_modules");
let f = super::fixture_root().join("resolve/abnormal-relative-without-node_modules");
let base = f.join("foo/bar/baz");
+7 -9
View File
@@ -55,18 +55,16 @@ fn nested_symlinks() {
}
#[test]
#[cfg_attr(target_family = "wasm", ignore)]
fn node_path_resolves_from_env() {
fn node_path_resolves_from_modules() {
let enhanced_resolve = dir().join("fixtures/enhanced-resolve/test/fixtures");
let project = fixture();
let node_path_root = enhanced_resolve.join("multiple-modules/node_modules");
let node_path = env::join_paths([node_path_root]).unwrap();
// SAFETY: this test sets NODE_PATH before constructing the resolver.
unsafe {
env::set_var("NODE_PATH", node_path);
}
let resolver = Resolver::new(ResolveOptions {
modules: vec!["node_modules".to_string(), node_path_root.to_string_lossy().to_string()],
..ResolveOptions::default()
});
let expected = enhanced_resolve.join("multiple-modules/node_modules/m1/a.js");
let resolved = Resolver::default().resolve(&project, "m1/a.js").map(|r| r.full_path());
assert_eq!(resolved, Ok(expected));
let result = resolver.resolve(&project, "m1/a.js").map(|r| r.full_path());
assert_eq!(result, Ok(expected));
}