mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 23:04:17 -05:00
feat(hint): Add test for hint
This commit is contained in:
parent
795b6e3480
commit
ce9fa6ebbf
3 changed files with 21 additions and 9 deletions
|
@ -65,9 +65,7 @@ fn main() {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let matching_exercise = |e: &&Exercise| {
|
let matching_exercise = |e: &&Exercise| name == e.name;
|
||||||
name == e.name
|
|
||||||
};
|
|
||||||
|
|
||||||
let exercise = exercises.iter().find(matching_exercise).unwrap_or_else(|| {
|
let exercise = exercises.iter().find(matching_exercise).unwrap_or_else(|| {
|
||||||
println!("No exercise found for your given name!");
|
println!("No exercise found for your given name!");
|
||||||
|
@ -83,7 +81,10 @@ fn main() {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let exercise = exercises.iter().find(|e| name == e.name).unwrap_or_else(|| {
|
let exercise = exercises
|
||||||
|
.iter()
|
||||||
|
.find(|e| name == e.name)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
println!("No exercise found for your given name!");
|
println!("No exercise found for your given name!");
|
||||||
std::process::exit(1)
|
std::process::exit(1)
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
name = "compFailure"
|
name = "compFailure"
|
||||||
path = "compFailure.rs"
|
path = "compFailure.rs"
|
||||||
mode = "compile"
|
mode = "compile"
|
||||||
hint = """"""
|
hint = ""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "testFailure"
|
name = "testFailure"
|
||||||
path = "testFailure.rs"
|
path = "testFailure.rs"
|
||||||
mode = "test"
|
mode = "test"
|
||||||
hint = """"""
|
hint = "Hello!"
|
||||||
|
|
|
@ -105,3 +105,14 @@ fn run_single_test_no_exercise() {
|
||||||
.assert()
|
.assert()
|
||||||
.code(1);
|
.code(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_hint_for_single_test() {
|
||||||
|
Command::cargo_bin("rustlings")
|
||||||
|
.unwrap()
|
||||||
|
.args(&["h", "testFailure"])
|
||||||
|
.current_dir("tests/fixture/failure")
|
||||||
|
.assert()
|
||||||
|
.code(0)
|
||||||
|
.stdout("Hello!\n");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue