diff options
author | Ondřej Čertík <ondrej@certik.us> | 2020-01-15 22:44:55 -0700 |
---|---|---|
committer | Ondřej Čertík <ondrej@certik.us> | 2020-01-15 22:44:55 -0700 |
commit | 7b53dd48556cf792359c030fcdb01693e1db45b4 (patch) | |
tree | ae18ad5d8d36bd67b5b584a18287df40ed7461f4 /tests/cli.rs | |
parent | c08b52b764ea3cc5e4c6853529aedaccff62e8e7 (diff) | |
download | fpm-7b53dd48556cf792359c030fcdb01693e1db45b4.tar.gz fpm-7b53dd48556cf792359c030fcdb01693e1db45b4.zip |
Add our own implementation of success()
Diffstat (limited to 'tests/cli.rs')
-rw-r--r-- | tests/cli.rs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/cli.rs b/tests/cli.rs index 09e42e9..ebdcd24 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,32 +1,42 @@ use std::process::Command; // Run programs use assert_cmd::prelude::*; // Add methods on commands use predicates::prelude::*; // Used for writing assertions +use assert_cmd::assert::Assert; + +// Our own function, so that we can better debug the failure +fn success(self0: Assert) -> Assert { + if !self0.get_output().status.success() { + let actual_code = self0.get_output().status.code().unwrap_or_else(|| { + panic!("INTERRUPTED") + }); + panic!("Non zero exit code: {}", actual_code); + } + self0 +} #[test] fn test_help() { let mut cmd = Command::cargo_bin("fpm").unwrap(); cmd.arg("--help"); - cmd.assert() - .success() + success(cmd.assert()) .stdout( predicate::str::contains("--help Prints help information")); } + #[test] fn test_1() { let mut build = Command::cargo_bin("fpm").unwrap(); build.arg("build") .current_dir("tests/1"); - build.assert() - .success() + success(build.assert()) .stdout(predicate::str::contains("Built target p1") .and(predicate::str::contains("TEST1 OK").not())); let mut run = Command::cargo_bin("fpm").unwrap(); run.arg("run") .current_dir("tests/1"); - run.assert() - .success() + success(run.assert()) .stdout(predicate::str::contains("TEST1 OK")); } @@ -35,15 +45,13 @@ fn test_2() { let mut build = Command::cargo_bin("fpm").unwrap(); build.arg("build") .current_dir("tests/2"); - build.assert() - .success() + success(build.assert()) .stdout(predicate::str::contains("Built target p1") .and(predicate::str::contains("TEST2 OK").not())); let mut run = Command::cargo_bin("fpm").unwrap(); run.arg("run") .current_dir("tests/2"); - run.assert() - .success() + success(run.assert()) .stdout(predicate::str::contains("TEST2 OK")); } |