summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyril Plisko <cyril.plisko@mountall.com>2017-12-04 07:31:40 -0500
committerCyril Plisko <cyril.plisko@mountall.com>2017-12-04 07:31:40 -0500
commit9dc4037547f164e529cb12f4fbc7b1caf673ee78 (patch)
tree2529f0e3821fc4b3e7aea1de333b1352e5d9e23a
parentfdfb11eb241bcd0358927c10552e7443f6ba582d (diff)
Assert path ends with "/bin/more" rather than equals to it.
Helps testing on different platforms, where location of "more" is not the same. I.e. /bin/more vs /usr/bin/more. Addresses #9
-rw-r--r--src/utils.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/utils.rs b/src/utils.rs
index cc67e40..4084b8a 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -77,11 +77,12 @@ pub fn isatty(fd: i32) -> bool {
mod tests {
use super::*;
- #[cfg(target_os = "linux")]
const MORE: &str = "/bin/more";
- #[cfg(target_os = "macos")]
- const MORE: &str = "/usr/bin/more";
+ fn assert_ends_with_bin_more(more: OsString) {
+ let good = more.to_str().map(|m| m.ends_with(MORE)).unwrap_or(false);
+ assert!(good, "{:?} doesn't end with {}", more, MORE);
+ }
#[test]
fn more_found_in_path() {
@@ -95,12 +96,12 @@ mod tests {
#[test]
fn which_more() {
- assert_eq!(which("more"), Some(OsString::from(MORE)));
+ which("more").map(assert_ends_with_bin_more);
}
#[test]
fn usr_bin_more_default_pager() {
- assert_eq!(find_pager("__RANDOM_NAME"), Some(OsString::from(MORE)));
+ find_pager("__RANDOM_NAME").map(assert_ends_with_bin_more);
}
#[test]