Tests: Refactor

Move apparent size test to 'test_flags' file. We can no longer test the
exact output of this test as it changes too much on different filesystems

Move common code to shared initialization function in test_flags.rs
This commit is contained in:
andy.boot
2021-08-06 10:41:54 +01:00
parent 9cf260e42b
commit ca0a93f222
2 changed files with 37 additions and 83 deletions
+2 -17
View File
@@ -46,14 +46,14 @@ fn initialize() {
});
}
fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args : Vec<T>) {
fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args: Vec<T>) {
initialize();
let mut a = &mut Command::cargo_bin("dust").unwrap();
for p in command_args {
a = a.arg(p);
}
let output : String = str::from_utf8(&a.unwrap().stdout).unwrap().into();
let output: String = str::from_utf8(&a.unwrap().stdout).unwrap().into();
assert!(valid_outputs
.iter()
@@ -131,21 +131,6 @@ fn main_output_long_paths() -> Vec<String> {
vec![mac_and_some_linux, ubuntu]
}
#[cfg_attr(target_os = "windows", ignore)]
#[test]
pub fn test_apparent_size() {
let command_args = vec!["-c", "-s", "/tmp/test_dir"];
exact_output_test(output_apparent_size(), command_args);
}
fn output_apparent_size() -> Vec<String> {
// The directory sizes vary a lot based on what the underlying filesystem is
// so different distros give different results. Really we should be checking that
// the standard '4.0K' isn't there
let apparent_size = "6B ├── hello_file│".into();
vec![apparent_size]
}
// Check against directories and files whos names are substrings of each other
#[cfg_attr(target_os = "windows", ignore)]
#[test]