Skip to content

Commit

Permalink
Make run-pass/env-home-dir.rs test more robust
Browse files Browse the repository at this point in the history
Remove the assumption that home_dir always returns Some

This allows the test to be executed with
[cross](https://github.com/japaric/cross).
  • Loading branch information
malbarbo committed Jan 29, 2018
1 parent 4e3901d commit 898fdcc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/test/run-pass/env-home-dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use std::env::*;
use std::path::PathBuf;

/// When HOME is not set, some platforms return `None`, but others return `Some` with a default.
/// Just check that it is not "/home/MountainView".
#[cfg(unix)]
fn main() {
let oldhome = var("HOME");
Expand All @@ -27,7 +30,7 @@ fn main() {
if cfg!(target_os = "android") {
assert!(home_dir().is_none());
} else {
assert!(home_dir().is_some());
assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView")));
}
}

Expand Down

0 comments on commit 898fdcc

Please sign in to comment.