Skip to content

Commit 85fec66

Browse files
committed
test: fix codcov workflo
1 parent 5e8f545 commit 85fec66

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

.github/workflows/codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626

2727
- uses: ./.github/actions/pnpm
2828

29+
- name: Setup Test Fixture
30+
working-directory: ./fixtures/pnp-global-cache-enabled
31+
run: yarn
32+
2933
- uses: Boshen/setup-rust@main
3034
with:
3135
cache-key: codecov

examples/resolver.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,25 @@ async fn main() {
2525
extension_alias: vec![(".js".into(), vec![".ts".into(), ".js".into()])],
2626
// ESM
2727
condition_names: vec!["node".into(), "import".into()],
28-
enable_pnp: true,
2928
// CJS
3029
// condition_names: vec!["node".into(), "require".into()],
3130
..ResolveOptions::default()
3231
};
3332
let mut ctx = Default::default();
3433

35-
let resolver = Resolver::new(options.clone());
36-
37-
match resolver
34+
match Resolver::new(options)
3835
.resolve_with_context(path, &specifier, &mut ctx)
3936
.await
4037
{
4138
Err(error) => println!("Error: {error}"),
4239
Ok(resolution) => println!("Resolved: {:?}", resolution.full_path()),
4340
};
4441

45-
let global_cache_path = PathBuf::from("/Users/bytedance/.yarn/berry/cache/@rspress-core-npm-2.0.3-c87d0adf5b-10c0.zip/node_modules/@rspress/core/dist/runtime/index.js");
42+
let mut sorted_file_deps = ctx.file_dependencies.iter().collect::<Vec<_>>();
43+
sorted_file_deps.sort();
44+
println!("file_deps: {:#?}", sorted_file_deps);
4645

47-
match resolver
48-
.resolve_with_context(&global_cache_path, "react-router-dom", &mut ctx)
49-
.await
50-
{
51-
Err(error) => println!("Error: {error}"),
52-
Ok(resolution) => println!("Resolved: {:?}", resolution.full_path()),
53-
};
46+
let mut sorted_missing = ctx.missing_dependencies.iter().collect::<Vec<_>>();
47+
sorted_missing.sort();
48+
println!("missing_deps: {:#?}", sorted_missing);
5449
}

src/tests/pnp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ async fn resolve_pnp_with_global_cache_enabled() {
166166
let module_root = resolved_to_global_cache.parent().unwrap();
167167
let module_root_str = module_root.to_string_lossy().replace('\\', "/");
168168

169+
#[cfg(target_os = "windows")]
170+
assert_that!(module_root_str.as_str()).contains("/Yarn/Berry/cache/lodash.zip");
171+
#[cfg(not(target_os = "windows"))]
169172
assert_that!(module_root_str.as_str()).contains("/.yarn/berry/cache/lodash.zip");
170173

171174
let resolve_from_global_cached = resolver.resolve(module_root, "./index.js").await.map(|r| {
@@ -175,5 +178,8 @@ async fn resolve_pnp_with_global_cache_enabled() {
175178
.to_string()
176179
});
177180

181+
#[cfg(target_os = "windows")]
182+
assert_that!(resolve_from_global_cached.unwrap()).contains("/Yarn/Berry/cache/lodash.zip");
183+
#[cfg(not(target_os = "windows"))]
178184
assert_that!(resolve_from_global_cached.unwrap()).contains("/.yarn/berry/cache/lodash.zip");
179185
}

0 commit comments

Comments
 (0)