From 898fdcc3eda5c5fa32e893b27f066d2dad77ea77 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 24 Jan 2018 15:11:15 -0200 Subject: [PATCH 1/2] Make run-pass/env-home-dir.rs test more robust Remove the assumption that home_dir always returns Some This allows the test to be executed with [cross](https://github.com/japaric/cross). --- src/test/run-pass/env-home-dir.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 22e440c6ffa51..449d3b044e920 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -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"); @@ -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"))); } } From adeb0aeb4a21fe3a944285ad72dab01c10765398 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 29 Jan 2018 13:28:23 -0500 Subject: [PATCH 2/2] move comment right onto the line in question --- src/test/run-pass/env-home-dir.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 449d3b044e920..9bbff1eeb81f3 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -16,9 +16,6 @@ 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"); @@ -30,6 +27,9 @@ fn main() { if cfg!(target_os = "android") { assert!(home_dir().is_none()); } else { + // When HOME is not set, some platforms return `None`, + // but others return `Some` with a default. + // Just check that it is not "/home/MountainView". assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); } }