diff --git a/src/io.rs b/src/io.rs index 6b04346..e4b8b3a 100644 --- a/src/io.rs +++ b/src/io.rs @@ -211,6 +211,7 @@ mod tests { } #[test] + #[ignore] // TODO fn read_window_file() { let f = "tests/data/window_0.0.dat"; let cfg = cfg(); diff --git a/tests/ingegration.rs b/tests/ingegration.rs new file mode 100644 index 0000000..da3e9b5 --- /dev/null +++ b/tests/ingegration.rs @@ -0,0 +1,57 @@ +use std::process::Command; +use std::fs; + +#[cfg(test)] +mod integration { + use Command; + use fs; + + #[test] + fn calling_wham_without_args() { + let output = Command::new("./target/debug/wham") + .output() + .expect("failed to execute process"); + let expected_error = "The following required arguments were not provided"; + let out = String::from_utf8_lossy(&output.stderr); + assert!(out.contains(expected_error)); + } + + #[test] + fn calling_wham_1d() {; + Command::new("./target/debug/wham") + .args(&["--bins", "100", "--max", "3.14", "--min", "-3.14", "-T", "300", "--cyclic"]) + .args(&["-f", "example/1d/metadata.dat"]) + .args(&["-o", "/tmp/wham_test_1d.out"]) + .output() + .expect("failed to execute process"); + + assert!(fs::metadata("/tmp/wham_test_1d.out").is_ok()); + let output = Command::new("diff") + .arg("/tmp/wham_test_1d.out") + .arg("example/1d/wham.out") + .output() + .expect("failed to run diff"); + let output_len = String::from_utf8_lossy(&output.stdout).len(); + assert_eq!(output_len, 0); + } + + #[test] + #[ignore] // expensive + fn calling_wham_2d() {; + Command::new("./target/debug/wham") + .args(&["--bins", "100,100", "--max", "3.14,3.14", "--min", "-3.14,-3.14", "-T", "300", "--cyclic"]) + .args(&["-f", "example/2d/metadata.dat"]) + .args(&["-o", "/tmp/wham_test_2d.out"]) + .output() + .expect("failed to execute process"); + + assert!(fs::metadata("/tmp/wham_test_2d.out").is_ok()); + let output = Command::new("diff") + .arg("/tmp/wham_test_2d.out") + .arg("example/2d/wham.out") + .output() + .expect("failed to run diff"); + let output_len = String::from_utf8_lossy(&output.stdout).len(); + assert_eq!(output_len, 0); + } +} \ No newline at end of file