From 8539efaf67059ddef23b6221b3fe4fa5bc185004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 14 Jan 2020 13:42:18 -0700 Subject: Add Rust tests --- tests/cli.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/cli.rs 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")); +} -- cgit v1.2.3 From a57157068dc9fcb1d37845479e45857d18bbfa80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 14 Jan 2020 14:18:47 -0700 Subject: Run tests in serial This fixes an issue on macOS where sometimes the CI seems to kill `fpm`, probably due to having too many parallel processes at the same time. --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3