Skip to content
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

strip_common test was failing #44

Merged
merged 1 commit into from
Jul 2, 2024
Merged
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: 4 additions & 8 deletions rinja_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,9 @@ mod test {

#[test]
fn test_strip_common() {
// Full path is returned instead of empty when the entire path is in common.
assert_eq!(strip_common(Path::new("home"), Path::new("home")), "home");

let cwd = std::env::current_dir().expect("current_dir failed");

// We need actual existing paths for `canonicalize` to work, so let's do that.
Expand All @@ -814,13 +817,6 @@ mod test {
entry.file_name().to_string_lossy()
);

#[cfg(target_os = "linux")]
{
// They both start with `/home` (normally), making the path empty, so in this case,
// the whole path should be returned.
assert_eq!(strip_common(&cwd, Path::new("/home")), "/home");
}

// In this case it cannot canonicalize `/a/b/c` so it returns the path as is.
assert_eq!(strip_common(&cwd, Path::new("/a/b/c")), "/a/b/c");
}
Expand All @@ -831,7 +827,7 @@ mod test {
assert!(num_lit(".").is_err());
// Should succeed.
assert_eq!(num_lit("1.2E-02").unwrap(), ("", "1.2E-02"));
// Not supported (because rust want a number before the `.`).
// Not supported because Rust wants a number before the `.`.
assert!(num_lit(".1").is_err());
assert!(num_lit(".1E-02").is_err());
// Not supported (voluntarily because of `1..` syntax).
Expand Down