Skip to content

Commit

Permalink
test: add macOS case
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Apr 15, 2024
1 parent b124699 commit 2950042
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tokio-console/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ mod tests {
use super::*;

#[test]
#[cfg(target_os = "linux")]
fn test_format_location() {
let mut location1 = proto::Location::default();
location1.file = Some(
Expand All @@ -569,4 +570,32 @@ mod tests {
);
assert_eq!(format_location(None), "<unknown location>");
}

#[test]
#[cfg(target_os = "macos")]
fn test_format_location_macos() {
let mut location1 = proto::Location::default();
location1.file = Some(
"/Users/user/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.0.1/src/lib.rs"
.to_string(),
);
let mut location2 = proto::Location::default();
location2.file =
Some("/Users/user/.cargo/git/checkouts/tokio-1.0.1/src/lib.rs".to_string());
let mut location3 = proto::Location::default();
location3.file = Some("/Users/user/projects/tokio-1.0.1/src/lib.rs".to_string());

assert_eq!(
format_location(Some(location1)),
"<cargo>/tokio-1.0.1/src/lib.rs"
);
assert_eq!(
format_location(Some(location2)),
"<cargo>/tokio-1.0.1/src/lib.rs"
);
assert_eq!(
format_location(Some(location3)),
"/Users/user/projects/tokio-1.0.1/src/lib.rs"
);
}
}

0 comments on commit 2950042

Please sign in to comment.