Skip to content

Commit

Permalink
Check target architecture as well
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Jan 27, 2022
1 parent 5518296 commit e651e4d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ impl ToString for Platform {

/// Read the current machine's platform.
pub fn platform() -> Platform {
match env::consts::OS {
"linux" => Platform::LinuxAmd64,
"macos" => Platform::MacOsAmd64,
"windows" => Platform::WindowsAmd64,
match (env::consts::OS, env::consts::ARCH) {
("linux", "x86_64") => Platform::LinuxAmd64,
("macos", "x86_64") => Platform::MacOsAmd64,
("windows", "x86_64") => Platform::WindowsAmd64,
_ => Platform::Unsupported,
}
}
Expand All @@ -35,19 +35,19 @@ mod tests {
use super::*;

#[test]
#[cfg(target_os = "linux")]
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
fn get_platform() {
assert_eq!(platform(), Platform::LinuxAmd64);
}

#[test]
#[cfg(target_os = "macos")]
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
fn get_platform() {
assert_eq!(platform(), Platform::MacOsAmd64);
}

#[test]
#[cfg(target_os = "windows")]
#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
fn get_platform() {
assert_eq!(platform(), Platform::WindowsAmd64);
}
Expand Down

0 comments on commit e651e4d

Please sign in to comment.