Skip to content

Runs tests on Windows #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ name: Rust

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Build
Expand Down
38 changes: 32 additions & 6 deletions src/lib_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,38 @@ mod tests {

for test_suite in test_suites.iter_mut() {
let manifest = &mut test_suite.manifest;
init_pnp_manifest(manifest, &PathBuf::from("/path/to/project/.pnp.cjs"));

#[cfg(windows)]
let manifest_path = "C:\\path\\to\\project\\.pnp.cjs";
#[cfg(not(windows))]
let manifest_path = "/path/to/project/.pnp.cjs";

init_pnp_manifest(manifest, &PathBuf::from(manifest_path));

for test in test_suite.tests.iter() {
let specifier = &test.imported;
let parent = &PathBuf::from(&test.importer).join("fooo");
let specifier
= &test.imported;

let mut importer
= test.importer.clone();

#[cfg(windows)] {
importer.replace_range(0..1, "C:\\");
importer.replace("/", "\\");
}

let mut expected = test.expected.clone();

#[cfg(windows)] {
importer.replace_range(0..1, "C:\\");
importer.replace("/", "\\");
}

let parent
= &PathBuf::from(&importer).join("my-file");

let manifest_copy = manifest.clone();
let manifest_copy
= manifest.clone();

let host = ResolutionHost {
find_pnp_manifest: Box::new(move |_| Ok(Some(manifest_copy.clone()))),
Expand All @@ -104,11 +129,12 @@ mod tests {
..Default::default()
};

let resolution = resolve_to_unqualified(specifier, parent, &config);
let resolution
= resolve_to_unqualified(specifier, parent, &config);

match resolution {
Ok(Resolution::Resolved(path, _subpath)) => {
assert_eq!(path.to_string_lossy(), test.expected, "{}", test.it);
assert_eq!(path.to_string_lossy(), expected, "{}", test.it);
}
Ok(Resolution::Skipped) => {
assert_eq!(specifier, &test.expected, "{}", test.it);
Expand Down
Loading