chore: Fix integration tests
This commit is contained in:
parent
7928122fce
commit
6177b6e126
|
@ -24,7 +24,7 @@ fn fails_when_in_wrong_dir() {
|
||||||
fn verify_all_success() {
|
fn verify_all_success() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.arg("v")
|
.arg("verify")
|
||||||
.current_dir("tests/fixture/success")
|
.current_dir("tests/fixture/success")
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
@ -34,7 +34,7 @@ fn verify_all_success() {
|
||||||
fn verify_fails_if_some_fails() {
|
fn verify_fails_if_some_fails() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.arg("v")
|
.arg("verify")
|
||||||
.current_dir("tests/fixture/failure")
|
.current_dir("tests/fixture/failure")
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
|
@ -44,7 +44,7 @@ fn verify_fails_if_some_fails() {
|
||||||
fn run_single_compile_success() {
|
fn run_single_compile_success() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "compSuccess"])
|
.args(&["run", "compSuccess"])
|
||||||
.current_dir("tests/fixture/success/")
|
.current_dir("tests/fixture/success/")
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
@ -54,7 +54,7 @@ fn run_single_compile_success() {
|
||||||
fn run_single_compile_failure() {
|
fn run_single_compile_failure() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "compFailure"])
|
.args(&["run", "compFailure"])
|
||||||
.current_dir("tests/fixture/failure/")
|
.current_dir("tests/fixture/failure/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
|
@ -64,7 +64,7 @@ fn run_single_compile_failure() {
|
||||||
fn run_single_test_success() {
|
fn run_single_test_success() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "testSuccess"])
|
.args(&["run", "testSuccess"])
|
||||||
.current_dir("tests/fixture/success/")
|
.current_dir("tests/fixture/success/")
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
@ -74,7 +74,7 @@ fn run_single_test_success() {
|
||||||
fn run_single_test_failure() {
|
fn run_single_test_failure() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "testFailure"])
|
.args(&["run", "testFailure"])
|
||||||
.current_dir("tests/fixture/failure/")
|
.current_dir("tests/fixture/failure/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
|
@ -84,7 +84,7 @@ fn run_single_test_failure() {
|
||||||
fn run_single_test_not_passed() {
|
fn run_single_test_not_passed() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "testNotPassed.rs"])
|
.args(&["run", "testNotPassed.rs"])
|
||||||
.current_dir("tests/fixture/failure/")
|
.current_dir("tests/fixture/failure/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
|
@ -94,7 +94,7 @@ fn run_single_test_not_passed() {
|
||||||
fn run_single_test_no_filename() {
|
fn run_single_test_no_filename() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.arg("r")
|
.arg("run")
|
||||||
.current_dir("tests/fixture/")
|
.current_dir("tests/fixture/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
|
@ -104,7 +104,7 @@ fn run_single_test_no_filename() {
|
||||||
fn run_single_test_no_exercise() {
|
fn run_single_test_no_exercise() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "compNoExercise.rs"])
|
.args(&["run", "compNoExercise.rs"])
|
||||||
.current_dir("tests/fixture/failure")
|
.current_dir("tests/fixture/failure")
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
|
@ -114,7 +114,7 @@ fn run_single_test_no_exercise() {
|
||||||
fn get_hint_for_single_test() {
|
fn get_hint_for_single_test() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["h", "testFailure"])
|
.args(&["hint", "testFailure"])
|
||||||
.current_dir("tests/fixture/failure")
|
.current_dir("tests/fixture/failure")
|
||||||
.assert()
|
.assert()
|
||||||
.code(0)
|
.code(0)
|
||||||
|
@ -131,10 +131,15 @@ fn all_exercises_require_confirmation() {
|
||||||
file.read_to_string(&mut s).unwrap();
|
file.read_to_string(&mut s).unwrap();
|
||||||
s
|
s
|
||||||
};
|
};
|
||||||
source.matches("// I AM NOT DONE").next().unwrap_or_else(|| panic!(
|
source
|
||||||
"There should be an `I AM NOT DONE` annotation in {:?}",
|
.matches("// I AM NOT DONE")
|
||||||
path
|
.next()
|
||||||
));
|
.unwrap_or_else(|| {
|
||||||
|
panic!(
|
||||||
|
"There should be an `I AM NOT DONE` annotation in {:?}",
|
||||||
|
path
|
||||||
|
)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +147,7 @@ fn all_exercises_require_confirmation() {
|
||||||
fn run_compile_exercise_does_not_prompt() {
|
fn run_compile_exercise_does_not_prompt() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "pending_exercise"])
|
.args(&["run", "pending_exercise"])
|
||||||
.current_dir("tests/fixture/state")
|
.current_dir("tests/fixture/state")
|
||||||
.assert()
|
.assert()
|
||||||
.code(0)
|
.code(0)
|
||||||
|
@ -153,7 +158,7 @@ fn run_compile_exercise_does_not_prompt() {
|
||||||
fn run_test_exercise_does_not_prompt() {
|
fn run_test_exercise_does_not_prompt() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "pending_test_exercise"])
|
.args(&["run", "pending_test_exercise"])
|
||||||
.current_dir("tests/fixture/state")
|
.current_dir("tests/fixture/state")
|
||||||
.assert()
|
.assert()
|
||||||
.code(0)
|
.code(0)
|
||||||
|
@ -164,7 +169,7 @@ fn run_test_exercise_does_not_prompt() {
|
||||||
fn run_single_test_success_with_output() {
|
fn run_single_test_success_with_output() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["--nocapture", "r", "testSuccess"])
|
.args(&["--nocapture", "run", "testSuccess"])
|
||||||
.current_dir("tests/fixture/success/")
|
.current_dir("tests/fixture/success/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(0)
|
.code(0)
|
||||||
|
@ -175,7 +180,7 @@ fn run_single_test_success_with_output() {
|
||||||
fn run_single_test_success_without_output() {
|
fn run_single_test_success_without_output() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(&["r", "testSuccess"])
|
.args(&["run", "testSuccess"])
|
||||||
.current_dir("tests/fixture/success/")
|
.current_dir("tests/fixture/success/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(0)
|
.code(0)
|
||||||
|
@ -192,26 +197,6 @@ fn run_rustlings_list() {
|
||||||
.success();
|
.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]
|
#[test]
|
||||||
fn run_rustlings_list_no_pending() {
|
fn run_rustlings_list_no_pending() {
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
|
@ -231,10 +216,7 @@ fn run_rustlings_list_both_done_and_pending() {
|
||||||
.current_dir("tests/fixture/state")
|
.current_dir("tests/fixture/state")
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
.stdout(
|
.stdout(predicates::str::contains("Done").and(predicates::str::contains("Pending")));
|
||||||
predicates::str::contains("Done")
|
|
||||||
.and(predicates::str::contains("Pending"))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -258,4 +240,3 @@ fn run_rustlings_list_without_done() {
|
||||||
.success()
|
.success()
|
||||||
.stdout(predicates::str::contains("Done").not());
|
.stdout(predicates::str::contains("Done").not());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue