From b3b1a867c47b206b73e5db44535d9950186b1719 Mon Sep 17 00:00:00 2001 From: bootandy Date: Sat, 7 Apr 2018 11:03:31 +0100 Subject: [PATCH] Fix tests on CI Files do not appear in predictable order - this order differs on different versions of linux :-(. --- src/tests.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 475b0dc..20e66cd 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -6,6 +6,7 @@ use super::*; use display::format_string; use std::fs::File; use std::io::Write; +use std::panic; use std::path::PathBuf; use std::process::Command; @@ -135,12 +136,30 @@ pub fn test_hard_sym_link() { format_string(dir_s, true, " 4.0K", ""), format_string(file_path_s, true, " 4.0K", "└──") ); + let r2 = format!( + "{} +{}", + format_string(dir_s, true, " 4.0K", ""), + format_string(link_name_s, true, " 4.0K", "└──") + ); - assert_cli::Assert::main_binary() - .with_args(&[dir_s]) - .stdout() - .contains(r) - .unwrap(); + // Because this is a hard link the file and hard link look identicle. Therefore + // we cannot guarantee which version will appear first. + // TODO: Consider adding predictable itteration order (sort file entries by name?) + let result = panic::catch_unwind(|| { + assert_cli::Assert::main_binary() + .with_args(&[dir_s]) + .stdout() + .contains(r) + .unwrap(); + }); + if result.is_err() { + assert_cli::Assert::main_binary() + .with_args(&[dir_s]) + .stdout() + .contains(r2) + .unwrap(); + } } //Check we don't recurse down an infinite symlink tree