From 3d11d7685b2c3478c35a09fbb7543c03f5043bbe Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Sun, 7 Apr 2019 17:49:34 +0100 Subject: [PATCH] Modify integration tests to fail on panic --- tests/fixture/failure/compFailure.rs | 3 ++ tests/fixture/{ => failure}/compNoExercise.rs | 0 tests/fixture/failure/info.toml | 7 +++ tests/fixture/failure/testFailure.rs | 4 ++ tests/fixture/{ => success}/compSuccess.rs | 0 tests/fixture/{ => success}/info.toml | 0 tests/fixture/{ => success}/testSuccess.rs | 0 tests/integration_tests.rs | 44 ++++++++++++++++--- 8 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 tests/fixture/failure/compFailure.rs rename tests/fixture/{ => failure}/compNoExercise.rs (100%) create mode 100644 tests/fixture/failure/info.toml create mode 100644 tests/fixture/failure/testFailure.rs rename tests/fixture/{ => success}/compSuccess.rs (100%) rename tests/fixture/{ => success}/info.toml (100%) rename tests/fixture/{ => success}/testSuccess.rs (100%) diff --git a/tests/fixture/failure/compFailure.rs b/tests/fixture/failure/compFailure.rs new file mode 100644 index 00000000..566856a8 --- /dev/null +++ b/tests/fixture/failure/compFailure.rs @@ -0,0 +1,3 @@ +fn main() { + let +} \ No newline at end of file diff --git a/tests/fixture/compNoExercise.rs b/tests/fixture/failure/compNoExercise.rs similarity index 100% rename from tests/fixture/compNoExercise.rs rename to tests/fixture/failure/compNoExercise.rs diff --git a/tests/fixture/failure/info.toml b/tests/fixture/failure/info.toml new file mode 100644 index 00000000..f4e7c0cb --- /dev/null +++ b/tests/fixture/failure/info.toml @@ -0,0 +1,7 @@ +[[exercises]] +path = "compFailure.rs" +mode = "compile" + +[[exercises]] +path = "testFailure.rs" +mode = "test" \ No newline at end of file diff --git a/tests/fixture/failure/testFailure.rs b/tests/fixture/failure/testFailure.rs new file mode 100644 index 00000000..b33a5d28 --- /dev/null +++ b/tests/fixture/failure/testFailure.rs @@ -0,0 +1,4 @@ +#[test] +fn passing() { + asset!(true); +} diff --git a/tests/fixture/compSuccess.rs b/tests/fixture/success/compSuccess.rs similarity index 100% rename from tests/fixture/compSuccess.rs rename to tests/fixture/success/compSuccess.rs diff --git a/tests/fixture/info.toml b/tests/fixture/success/info.toml similarity index 100% rename from tests/fixture/info.toml rename to tests/fixture/success/info.toml diff --git a/tests/fixture/testSuccess.rs b/tests/fixture/success/testSuccess.rs similarity index 100% rename from tests/fixture/testSuccess.rs rename to tests/fixture/success/testSuccess.rs diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 01c4744d..a0779182 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -13,7 +13,7 @@ fn fails_when_in_wrong_dir() { .unwrap() .current_dir("tests/") .assert() - .failure(); + .code(1); } #[test] @@ -21,31 +21,61 @@ fn verify_all_success() { Command::cargo_bin("rustlings") .unwrap() .arg("v") - .current_dir("tests/fixture/") + .current_dir("tests/fixture/success") .assert() .success(); } +#[test] +fn verify_all_failure() { + Command::cargo_bin("rustlings") + .unwrap() + .arg("v") + .current_dir("tests/fixture/failure") + .assert() + .code(1); +} + #[test] fn run_single_compile_success() { Command::cargo_bin("rustlings") .unwrap() .args(&["r", "compSuccess.rs"]) - .current_dir("tests/fixture/") + .current_dir("tests/fixture/success/") .assert() .success(); } +#[test] +fn run_single_compile_failure() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["r", "compFailure.rs"]) + .current_dir("tests/fixture/failure/") + .assert() + .code(1); +} + #[test] fn run_single_test_success() { Command::cargo_bin("rustlings") .unwrap() .args(&["r", "testSuccess.rs"]) - .current_dir("tests/fixture/") + .current_dir("tests/fixture/success/") .assert() .success(); } +#[test] +fn run_single_test_failure() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["r", "testFailure.rs"]) + .current_dir("tests/fixture/failure/") + .assert() + .code(1); +} + #[test] fn run_single_test_no_filename() { Command::cargo_bin("rustlings") @@ -53,7 +83,7 @@ fn run_single_test_no_filename() { .arg("r") .current_dir("tests/fixture/") .assert() - .failure(); + .code(1); } #[test] @@ -61,7 +91,7 @@ fn run_single_test_no_exercise() { Command::cargo_bin("rustlings") .unwrap() .args(&["r", "compNoExercise.rs"]) - .current_dir("tests/fixture/") + .current_dir("tests/fixture/failure") .assert() - .failure(); + .code(1); }