Skip to content

Commit

Permalink
make tests pass on Windows
Browse files Browse the repository at this point in the history
Also add CI for Windows.
  • Loading branch information
sunshowers committed Dec 14, 2021
1 parent 08fabb3 commit 1ff07b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ env:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ all-features = true

[dependencies]
camino = { version = "1.0.5", optional = true }

[dev-dependencies]
cfg-if = "1.0.0"
18 changes: 15 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,24 @@ pub use crate::utf8_paths::*;
#[cfg(test)]
mod tests {
use super::*;
use cfg_if::cfg_if;

#[test]
fn test_absolute() {
assert_diff_paths("/foo", "/bar", Some("../foo"));
assert_diff_paths("/foo", "bar", Some("/foo"));
assert_diff_paths("foo", "/bar", None);
fn abs(path: &str) -> String {
// Absolute paths look different on Windows vs Unix.
cfg_if! {
if #[cfg(windows)] {
format!("C:\\{}", path)
} else {
format!("/{}", path)
}
}
}

assert_diff_paths(&abs("foo"), &abs("bar"), Some("../foo"));
assert_diff_paths(&abs("foo"), "bar", Some(&abs("foo")));
assert_diff_paths("foo", &abs("bar"), None);
assert_diff_paths("foo", "bar", Some("../foo"));
}

Expand Down

0 comments on commit 1ff07b7

Please sign in to comment.