diff options
author | Ondřej Čertík <ondrej@certik.us> | 2020-01-14 21:31:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-14 21:31:04 -0700 |
commit | 69949a5ff1fd38ccb8080c424bb14a59bc718757 (patch) | |
tree | 917e2a3962f4a533464f510352be81385b9d764f | |
parent | 772d16a78abda39f2b3d6d3bb91253835bf0ff99 (diff) | |
parent | a57157068dc9fcb1d37845479e45857d18bbfa80 (diff) | |
download | fpm-69949a5ff1fd38ccb8080c424bb14a59bc718757.tar.gz fpm-69949a5ff1fd38ccb8080c424bb14a59bc718757.zip |
Merge pull request #13 from certik/test5
Add Rust tests
-rw-r--r-- | .github/workflows/CI.yml | 2 | ||||
-rw-r--r-- | tests/cli.rs | 49 |
2 files changed, 50 insertions, 1 deletions
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3fc511f..a27a108 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -64,7 +64,7 @@ jobs: - name: Run tests run: | - cargo test --verbose + cargo test --verbose -j1 # TODO: integrate these with `cargo test` above - name: Run manual tests diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..09e42e9 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,49 @@ +use std::process::Command; // Run programs +use assert_cmd::prelude::*; // Add methods on commands +use predicates::prelude::*; // Used for writing assertions + +#[test] +fn test_help() { + let mut cmd = Command::cargo_bin("fpm").unwrap(); + cmd.arg("--help"); + cmd.assert() + .success() + .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() + .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() + .stdout(predicate::str::contains("TEST1 OK")); +} + +#[test] +fn test_2() { + let mut build = Command::cargo_bin("fpm").unwrap(); + build.arg("build") + .current_dir("tests/2"); + build.assert() + .success() + .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() + .stdout(predicate::str::contains("TEST2 OK")); +} |