From b7010aae8bc4c546503b9736aafe99a4fc7273bf Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Tue, 25 Feb 2020 09:57:51 -0800 Subject: Move old stuff to archive folder --- tests/cli.rs | 103 ----------------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 tests/cli.rs (limited to 'tests/cli.rs') 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 { - status.signal() -} - -#[cfg(not(unix))] -fn get_signal(_status: std::process::ExitStatus) -> Option { - 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")); -} -- cgit v1.2.3