diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b80e0f..4a41a19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/src/lib_tests.rs b/src/lib_tests.rs index 2538011..e1fd762 100644 --- a/src/lib_tests.rs +++ b/src/lib_tests.rs @@ -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()))), @@ -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);