From 08752d0ed24c4a02818eb292c20eff1625be324d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Tue, 3 Jun 2025 11:54:45 +0200 Subject: [PATCH 1/3] Runs tests on Windows --- .github/workflows/ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 From 9b6f028a5d02150075811ab8a45b466538b9091e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Tue, 3 Jun 2025 15:43:06 +0200 Subject: [PATCH 2/3] Uses Windows paths --- src/lib_tests.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/lib_tests.rs b/src/lib_tests.rs index 2538011..4c86b4e 100644 --- a/src/lib_tests.rs +++ b/src/lib_tests.rs @@ -89,10 +89,29 @@ mod tests { init_pnp_manifest(manifest, &PathBuf::from("/path/to/project/.pnp.cjs")); for test in test_suite.tests.iter() { - let specifier = &test.imported; - let parent = &PathBuf::from(&test.importer).join("fooo"); + let specifier + = &test.imported; - let manifest_copy = manifest.clone(); + 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 host = ResolutionHost { find_pnp_manifest: Box::new(move |_| Ok(Some(manifest_copy.clone()))), @@ -104,11 +123,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); From f54a52b7cdacf83d58835aba12b18202fd286a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Tue, 3 Jun 2025 15:47:50 +0200 Subject: [PATCH 3/3] Updates the manifest path depending on the system --- src/lib_tests.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib_tests.rs b/src/lib_tests.rs index 4c86b4e..e1fd762 100644 --- a/src/lib_tests.rs +++ b/src/lib_tests.rs @@ -86,7 +86,13 @@ 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