diff options
author | Laurence Kedward <laurence.kedward@bristol.ac.uk> | 2020-12-09 16:16:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 16:16:23 +0000 |
commit | 4eba2e0ee99d8d2ace1173d149ad2cf16910a705 (patch) | |
tree | e85cf37b2a1aedf23c1314e5102735f55abb8d36 /archive/tests/cli.rs | |
parent | a062554e80c3718881c1be8edb0e7220e37fbd23 (diff) | |
parent | b384031eb4099c66805156d0fa65e67a650a13e0 (diff) | |
download | fpm-4eba2e0ee99d8d2ace1173d149ad2cf16910a705.tar.gz fpm-4eba2e0ee99d8d2ace1173d149ad2cf16910a705.zip |
Merge pull request #281 from awvwgk/cleanup-archive
Cleanup: Remove archived Rust prototype
Diffstat (limited to 'archive/tests/cli.rs')
-rw-r--r-- | archive/tests/cli.rs | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/archive/tests/cli.rs b/archive/tests/cli.rs deleted file mode 100644 index b099721..0000000 --- a/archive/tests/cli.rs +++ /dev/null @@ -1,103 +0,0 @@ -use assert_cmd::prelude::OutputAssertExt; // Add methods on commands -use predicates::prelude::{predicate, PredicateBooleanExt}; // Used for writing assertions -#[cfg(unix)] -use std::os::unix::process::ExitStatusExt; - -pub trait Success2 { - // Our own function with better reporting of errors - fn success2(self) -> Self; -} - -#[cfg(unix)] -fn get_signal(status: std::process::ExitStatus) -> Option<i32> { - status.signal() -} - -#[cfg(not(unix))] -fn get_signal(_status: std::process::ExitStatus) -> Option<i32> { - None -} - -impl Success2 for assert_cmd::assert::Assert { - fn success2(self) -> Self { - if !self.get_output().status.success() { - let output = self.get_output(); - let code = output.status.code(); - println!("status: {}", output.status); - println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); - println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); - if cfg!(unix) { - if code.is_none() { - let signal = get_signal(output.status).unwrap(); - panic!("INTERRUPTED with signal: {}", signal); - } - } - let actual_code = code.unwrap(); - println!("code: {}", actual_code); - panic!("Non zero exit code"); - } - self - } -} - -fn fpm_bin() -> std::process::Command { - let mut fpm_bin_relative: std::path::PathBuf = ["target", "debug", "fpm"].iter().collect(); - fpm_bin_relative.set_extension(std::env::consts::EXE_EXTENSION); - let fpm_bin_absolute = std::fs::canonicalize(fpm_bin_relative).unwrap(); - std::process::Command::new(fpm_bin_absolute.to_str().unwrap()) -} - -#[test] -fn test_help() { - let mut cmd = fpm_bin(); - cmd.arg("--help"); - cmd.assert() - .success2() - .stdout( - predicate::str::contains("--help Prints help information")); -} - - -#[test] -fn test_1() { - let mut build = fpm_bin(); - build.arg("build") - .arg("--target-dir") - .arg("build-test") - .current_dir("tests/1"); - build.assert() - .success2() - .stdout(predicate::str::contains("Built target p1") - .and(predicate::str::contains("TEST1 OK").not())); - - let mut run = fpm_bin(); - run.arg("run") - .arg("--target-dir") - .arg("build-test") - .current_dir("tests/1"); - run.assert() - .success2() - .stdout(predicate::str::contains("TEST1 OK")); -} - -#[test] -fn test_2() { - let mut build = fpm_bin(); - build.arg("build") - .arg("--target-dir") - .arg("build-test") - .current_dir("tests/2"); - build.assert() - .success2() - .stdout(predicate::str::contains("Built target p1") - .and(predicate::str::contains("TEST2 OK").not())); - - let mut run = fpm_bin(); - run.arg("run") - .arg("--target-dir") - .arg("build-test") - .current_dir("tests/2"); - run.assert() - .success2() - .stdout(predicate::str::contains("TEST2 OK")); -} |