Skip to content

Commit

Permalink
chore: Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shadows-withal committed Apr 21, 2021
1 parent 7928122 commit 6177b6e
Showing 1 changed file with 24 additions and 43 deletions.
67 changes: 24 additions & 43 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn fails_when_in_wrong_dir() {
fn verify_all_success() {
Command::cargo_bin("rustlings")
.unwrap()
.arg("v")
.arg("verify")
.current_dir("tests/fixture/success")
.assert()
.success();
Expand All @@ -34,7 +34,7 @@ fn verify_all_success() {
fn verify_fails_if_some_fails() {
Command::cargo_bin("rustlings")
.unwrap()
.arg("v")
.arg("verify")
.current_dir("tests/fixture/failure")
.assert()
.code(1);
Expand All @@ -44,7 +44,7 @@ fn verify_fails_if_some_fails() {
fn run_single_compile_success() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "compSuccess"])
.args(&["run", "compSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.success();
Expand All @@ -54,7 +54,7 @@ fn run_single_compile_success() {
fn run_single_compile_failure() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "compFailure"])
.args(&["run", "compFailure"])
.current_dir("tests/fixture/failure/")
.assert()
.code(1);
Expand All @@ -64,7 +64,7 @@ fn run_single_compile_failure() {
fn run_single_test_success() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "testSuccess"])
.args(&["run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.success();
Expand All @@ -74,7 +74,7 @@ fn run_single_test_success() {
fn run_single_test_failure() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "testFailure"])
.args(&["run", "testFailure"])
.current_dir("tests/fixture/failure/")
.assert()
.code(1);
Expand All @@ -84,7 +84,7 @@ fn run_single_test_failure() {
fn run_single_test_not_passed() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "testNotPassed.rs"])
.args(&["run", "testNotPassed.rs"])
.current_dir("tests/fixture/failure/")
.assert()
.code(1);
Expand All @@ -94,7 +94,7 @@ fn run_single_test_not_passed() {
fn run_single_test_no_filename() {
Command::cargo_bin("rustlings")
.unwrap()
.arg("r")
.arg("run")
.current_dir("tests/fixture/")
.assert()
.code(1);
Expand All @@ -104,7 +104,7 @@ fn run_single_test_no_filename() {
fn run_single_test_no_exercise() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "compNoExercise.rs"])
.args(&["run", "compNoExercise.rs"])
.current_dir("tests/fixture/failure")
.assert()
.code(1);
Expand All @@ -114,7 +114,7 @@ fn run_single_test_no_exercise() {
fn get_hint_for_single_test() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["h", "testFailure"])
.args(&["hint", "testFailure"])
.current_dir("tests/fixture/failure")
.assert()
.code(0)
Expand All @@ -131,18 +131,23 @@ fn all_exercises_require_confirmation() {
file.read_to_string(&mut s).unwrap();
s
};
source.matches("// I AM NOT DONE").next().unwrap_or_else(|| panic!(
"There should be an `I AM NOT DONE` annotation in {:?}",
path
));
source
.matches("// I AM NOT DONE")
.next()
.unwrap_or_else(|| {
panic!(
"There should be an `I AM NOT DONE` annotation in {:?}",
path
)
});
}
}

#[test]
fn run_compile_exercise_does_not_prompt() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "pending_exercise"])
.args(&["run", "pending_exercise"])
.current_dir("tests/fixture/state")
.assert()
.code(0)
Expand All @@ -153,7 +158,7 @@ fn run_compile_exercise_does_not_prompt() {
fn run_test_exercise_does_not_prompt() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "pending_test_exercise"])
.args(&["run", "pending_test_exercise"])
.current_dir("tests/fixture/state")
.assert()
.code(0)
Expand All @@ -164,7 +169,7 @@ fn run_test_exercise_does_not_prompt() {
fn run_single_test_success_with_output() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["--nocapture", "r", "testSuccess"])
.args(&["--nocapture", "run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.code(0)
Expand All @@ -175,7 +180,7 @@ fn run_single_test_success_with_output() {
fn run_single_test_success_without_output() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["r", "testSuccess"])
.args(&["run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.code(0)
Expand All @@ -192,26 +197,6 @@ fn run_rustlings_list() {
.success();
}

#[test]
fn run_rustlings_list_conflicting_display_options() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list", "--names", "--paths"])
.current_dir("tests/fixture/success")
.assert()
.failure();
}

#[test]
fn run_rustlings_list_conflicting_solve_options() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list", "--solved", "--unsolved"])
.current_dir("tests/fixture/success")
.assert()
.failure();
}

#[test]
fn run_rustlings_list_no_pending() {
Command::cargo_bin("rustlings")
Expand All @@ -231,10 +216,7 @@ fn run_rustlings_list_both_done_and_pending() {
.current_dir("tests/fixture/state")
.assert()
.success()
.stdout(
predicates::str::contains("Done")
.and(predicates::str::contains("Pending"))
);
.stdout(predicates::str::contains("Done").and(predicates::str::contains("Pending")));
}

#[test]
Expand All @@ -258,4 +240,3 @@ fn run_rustlings_list_without_done() {
.success()
.stdout(predicates::str::contains("Done").not());
}

0 comments on commit 6177b6e

Please sign in to comment.