Skip to content

Commit d246536

Browse files
committed
chore: testing on CI
1 parent 0400f4f commit d246536

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
strategy:
1515
matrix:
1616
os:
17-
- ubuntu-latest
18-
- macos-latest
17+
# - ubuntu-latest
18+
# - macos-latest
1919
- windows-latest
2020
runs-on: ${{ matrix.os }}
2121
steps:
@@ -35,4 +35,4 @@ jobs:
3535
run: cargo build
3636

3737
- name: Run tests
38-
run: cargo test
38+
run: cargo test -- --nocapture

src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,26 @@ pub fn init_pnp_manifest<P: AsRef<Path>>(manifest: &mut Manifest, p: P) {
292292

293293
for (name, ranges) in manifest.package_registry_data.iter_mut() {
294294
for (reference, info) in ranges.iter_mut() {
295+
println!(
296+
"manifest.manifest_dir, {}",
297+
manifest.manifest_dir.to_string_lossy()
298+
);
299+
295300
let package_location = manifest.manifest_dir.join(info.package_location.clone());
296301

302+
println!("package_location: {}", package_location.to_string_lossy());
303+
297304
let normalized_location = util::normalize_path(&package_location.to_string_lossy());
298305

306+
println!("normalized_location: {}", normalized_location);
307+
299308
info.package_location = PathBuf::from(normalized_location);
300309

310+
println!(
311+
"info.package_location: {}",
312+
info.package_location.to_string_lossy()
313+
);
314+
301315
if !info.discard_from_lookup {
302316
manifest.location_trie.insert(
303317
&info.package_location,
@@ -349,6 +363,12 @@ pub fn find_locator<'a, P: AsRef<Path>>(
349363
}
350364
}
351365

366+
println!("path {}", path.as_ref().to_string_lossy());
367+
368+
let path = util::normalize_path(path.as_ref().to_string_lossy());
369+
370+
println!("path {}", path);
371+
352372
manifest.location_trie.get_ancestor_value(&path)
353373
}
354374

src/lib_tests.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod tests {
2323
use super::*;
2424
use crate::{
2525
init_pnp_manifest, load_pnp_manifest, parse_bare_identifier, resolve_to_unqualified,
26-
resolve_to_unqualified_via_manifest, ResolutionHost,
26+
resolve_to_unqualified_via_manifest, util, ResolutionHost,
2727
};
2828

2929
#[test]
@@ -191,11 +191,12 @@ mod tests {
191191
)
192192
.unwrap();
193193

194-
let global_cache = dirs::home_dir()
195-
.unwrap()
196-
.join(".yarn")
197-
.join("berry")
198-
.join("cache");
194+
let home_dir = dirs::home_dir().unwrap();
195+
196+
#[cfg(windows)]
197+
let global_cache = home_dir.join("AppData\\Local\\Yarn\\Berry");
198+
#[cfg(not(windows))]
199+
let global_cache = home_dir.join(".yarn/berry/cache");
199200

200201
let result = resolve_to_unqualified_via_manifest(
201202
&manifest,
@@ -210,12 +211,15 @@ mod tests {
210211
match result {
211212
Ok(Resolution::Resolved(path, subpath)) => {
212213
assert_eq!(
213-
path,
214-
global_cache
215-
.join("source-map-npm-0.6.1-1a3621db16-10c0.zip")
216-
.join("node_modules")
217-
.join("source-map")
218-
.join("")
214+
path.to_string_lossy(),
215+
util::normalize_path(
216+
global_cache
217+
.join("source-map-npm-0.6.1-1a3621db16-10c0.zip")
218+
.join("node_modules")
219+
.join("source-map")
220+
.join("")
221+
.to_string_lossy()
222+
)
219223
);
220224
assert_eq!(subpath, None);
221225
}

src/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde::{de::Error, Deserialize, Deserializer};
33
use std::borrow::Cow;
44

55
use path_slash::PathBufExt;
6-
use std::path::{Path, PathBuf};
6+
use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR};
77

88
#[derive(Debug, Default, Clone)]
99
pub struct Trie<T> {
@@ -39,7 +39,9 @@ pub fn normalize_path<P: AsRef<str>>(original: P) -> String {
3939
let p = PathBuf::from(original_str);
4040
let mut str = clean_path::clean(p).to_slash_lossy().to_string();
4141

42-
if original_str.ends_with('/') && !str.ends_with('/') {
42+
if (original_str.ends_with('/') || original_str.ends_with(MAIN_SEPARATOR_STR))
43+
&& !str.ends_with('/')
44+
{
4345
str.push('/');
4446
}
4547

0 commit comments

Comments
 (0)