diff options
author | Brad Richardson <brichardson@structint.com> | 2020-02-25 09:57:51 -0800 |
---|---|---|
committer | Brad Richardson <brichardson@structint.com> | 2020-02-25 09:57:51 -0800 |
commit | b7010aae8bc4c546503b9736aafe99a4fc7273bf (patch) | |
tree | 295158d3e02bad30d265815adfd6b0eed6a3a18b /tests/cli.rs | |
parent | 2292bbd1d57c97d800e87e1cb6ccd1981ad50333 (diff) | |
download | fpm-b7010aae8bc4c546503b9736aafe99a4fc7273bf.tar.gz fpm-b7010aae8bc4c546503b9736aafe99a4fc7273bf.zip |
Move old stuff to archive folder
Diffstat (limited to 'tests/cli.rs')
-rw-r--r-- | tests/cli.rs | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/tests/cli.rs b/tests/cli.rs deleted file mode 100644 index b099721..0000000 --- a/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")); -} |