diff --git a/Cargo.toml b/Cargo.toml index ddf3c703..685e8ac8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,7 @@ [workspace] resolver = "2" exclude = [ - "tests/fixture/failure", - "tests/fixture/state", - "tests/fixture/success", + "tests/test_exercises", "dev", ] diff --git a/tests/fixture/failure/Cargo.toml b/tests/fixture/failure/Cargo.toml deleted file mode 100644 index 7ee2f068..00000000 --- a/tests/fixture/failure/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "failure" -edition = "2021" -publish = false - -[[bin]] -name = "compFailure" -path = "exercises/compFailure.rs" - -[[bin]] -name = "compNoExercise" -path = "exercises/compNoExercise.rs" - -[[bin]] -name = "testFailure" -path = "exercises/testFailure.rs" - -[[bin]] -name = "testNotPassed" -path = "exercises/testNotPassed.rs" diff --git a/tests/fixture/failure/exercises/testFailure.rs b/tests/fixture/failure/exercises/testFailure.rs deleted file mode 100644 index fcbcf90a..00000000 --- a/tests/fixture/failure/exercises/testFailure.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() {} - -#[test] -fn passing() { - asset!(true); -} diff --git a/tests/fixture/failure/exercises/testNotPassed.rs b/tests/fixture/failure/exercises/testNotPassed.rs deleted file mode 100644 index de0d61c0..00000000 --- a/tests/fixture/failure/exercises/testNotPassed.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() {} - -#[test] -fn not_passing() { - assert!(false); -} diff --git a/tests/fixture/failure/info.toml b/tests/fixture/failure/info.toml deleted file mode 100644 index 554607a8..00000000 --- a/tests/fixture/failure/info.toml +++ /dev/null @@ -1,10 +0,0 @@ -format_version = 1 - -[[exercises]] -name = "compFailure" -test = false -hint = "" - -[[exercises]] -name = "testFailure" -hint = "Hello!" diff --git a/tests/fixture/state/Cargo.toml b/tests/fixture/state/Cargo.toml deleted file mode 100644 index adbd8ab1..00000000 --- a/tests/fixture/state/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "state" -edition = "2021" -publish = false - -[[bin]] -name = "pending_exercise" -path = "exercises/pending_exercise.rs" - -[[bin]] -name = "pending_test_exercise" -path = "exercises/pending_test_exercise.rs" - -[[bin]] -name = "finished_exercise" -path = "exercises/finished_exercise.rs" diff --git a/tests/fixture/state/exercises/pending_exercise.rs b/tests/fixture/state/exercises/pending_exercise.rs deleted file mode 100644 index f328e4d9..00000000 --- a/tests/fixture/state/exercises/pending_exercise.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() {} diff --git a/tests/fixture/state/exercises/pending_test_exercise.rs b/tests/fixture/state/exercises/pending_test_exercise.rs deleted file mode 100644 index 718e1dbb..00000000 --- a/tests/fixture/state/exercises/pending_test_exercise.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() {} - -#[test] -fn it_works() {} diff --git a/tests/fixture/state/info.toml b/tests/fixture/state/info.toml deleted file mode 100644 index ff0b932e..00000000 --- a/tests/fixture/state/info.toml +++ /dev/null @@ -1,15 +0,0 @@ -format_version = 1 - -[[exercises]] -name = "pending_exercise" -test = false -hint = """""" - -[[exercises]] -name = "pending_test_exercise" -hint = """""" - -[[exercises]] -name = "finished_exercise" -test = false -hint = """""" diff --git a/tests/fixture/success/Cargo.toml b/tests/fixture/success/Cargo.toml deleted file mode 100644 index 028cf35a..00000000 --- a/tests/fixture/success/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "success" -edition = "2021" -publish = false - -[[bin]] -name = "compSuccess" -path = "exercises/compSuccess.rs" - -[[bin]] -name = "testSuccess" -path = "exercises/testSuccess.rs" diff --git a/tests/fixture/success/exercises/compSuccess.rs b/tests/fixture/success/exercises/compSuccess.rs deleted file mode 100644 index f328e4d9..00000000 --- a/tests/fixture/success/exercises/compSuccess.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() {} diff --git a/tests/fixture/success/exercises/testSuccess.rs b/tests/fixture/success/exercises/testSuccess.rs deleted file mode 100644 index 4296cf61..00000000 --- a/tests/fixture/success/exercises/testSuccess.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() {} - -#[test] -fn passing() { - println!("THIS TEST TOO SHALL PASS"); - assert!(true); -} diff --git a/tests/fixture/success/info.toml b/tests/fixture/success/info.toml deleted file mode 100644 index d66d7d47..00000000 --- a/tests/fixture/success/info.toml +++ /dev/null @@ -1,10 +0,0 @@ -format_version = 1 - -[[exercises]] -name = "compSuccess" -test = false -hint = """""" - -[[exercises]] -name = "testSuccess" -hint = """""" diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index d5afd2ca..f21ee2f6 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -91,99 +91,62 @@ impl<'a> Cmd<'a> { } #[test] -fn fails_when_in_wrong_dir() { +fn wrong_dir() { Cmd::default().current_dir("tests").fail(); } #[test] -fn run_single_compile_success() { +fn run_compilation_success() { Cmd::default() - .current_dir("tests/fixture/success") - .args(&["run", "compSuccess"]) + .current_dir("tests/test_exercises") + .args(&["run", "compilation_success"]) .success(); } #[test] -fn run_single_compile_failure() { +fn run_compilation_failure() { Cmd::default() - .current_dir("tests/fixture/failure") - .args(&["run", "compFailure"]) + .current_dir("tests/test_exercises") + .args(&["run", "compilation_failure"]) .fail(); } #[test] -fn run_single_test_success() { +fn run_test_success() { Cmd::default() - .current_dir("tests/fixture/success") - .args(&["run", "testSuccess"]) + .current_dir("tests/test_exercises") + .args(&["run", "test_success"]) + .stdout("\nOutput from `main` function\n") .success(); } #[test] -fn run_single_test_failure() { +fn run_test_failure() { Cmd::default() - .current_dir("tests/fixture/failure") - .args(&["run", "testFailure"]) + .current_dir("tests/test_exercises") + .args(&["run", "test_failure"]) .fail(); } #[test] -fn run_single_test_not_passed() { +fn run_exercise_not_in_info() { Cmd::default() - .current_dir("tests/fixture/failure") - .args(&["run", "testNotPassed.rs"]) + .current_dir("tests/test_exercises") + .args(&["run", "not_in_info"]) .fail(); } #[test] -fn run_single_test_no_exercise() { - Cmd::default() - .current_dir("tests/fixture/failure") - .args(&["run", "compNoExercise.rs"]) - .fail(); -} - -#[test] -fn reset_single_exercise() { - Cmd::default().args(&["reset", "intro1"]).success(); -} - -#[test] -fn reset_no_exercise() { +fn reset_without_exercise_name() { Cmd::default().args(&["reset"]).fail(); } #[test] -fn get_hint_for_single_test() { +fn hint() { Cmd::default() - .current_dir("tests/fixture/failure") - .args(&["hint", "testFailure"]) - .stdout("Hello!\n") + .current_dir("tests/test_exercises") + .args(&["hint", "test_failure"]) + .stdout("The answer to everything: 42\n") .full_stdout() .success(); } - -#[test] -fn run_compile_exercise_does_not_prompt() { - Cmd::default() - .current_dir("tests/fixture/state") - .args(&["run", "pending_exercise"]) - .success(); -} - -#[test] -fn run_test_exercise_does_not_prompt() { - Cmd::default() - .current_dir("tests/fixture/state") - .args(&["run", "pending_test_exercise"]) - .success(); -} - -#[test] -fn run_single_test_success_with_output() { - Cmd::default() - .current_dir("tests/fixture/success") - .args(&["run", "testSuccess"]) - .stdout("\nTHIS TEST TOO SHALL PASS\n") - .success(); -} diff --git a/tests/test_exercises/Cargo.toml b/tests/test_exercises/Cargo.toml new file mode 100644 index 00000000..6b817518 --- /dev/null +++ b/tests/test_exercises/Cargo.toml @@ -0,0 +1,11 @@ +bin = [ + { name = "compilation_success", path = "exercises/compilation_success.rs" }, + { name = "compilation_failure", path = "exercises/compilation_failure.rs" }, + { name = "test_success", path = "exercises/test_success.rs" }, + { name = "test_failure", path = "exercises/test_failure.rs" }, +] + +[package] +name = "test_exercises" +edition = "2021" +publish = false diff --git a/tests/fixture/failure/exercises/compFailure.rs b/tests/test_exercises/exercises/compilation_failure.rs similarity index 100% rename from tests/fixture/failure/exercises/compFailure.rs rename to tests/test_exercises/exercises/compilation_failure.rs diff --git a/tests/fixture/failure/exercises/compNoExercise.rs b/tests/test_exercises/exercises/compilation_success.rs similarity index 100% rename from tests/fixture/failure/exercises/compNoExercise.rs rename to tests/test_exercises/exercises/compilation_success.rs diff --git a/tests/fixture/state/exercises/finished_exercise.rs b/tests/test_exercises/exercises/not_in_info.rs similarity index 100% rename from tests/fixture/state/exercises/finished_exercise.rs rename to tests/test_exercises/exercises/not_in_info.rs diff --git a/tests/test_exercises/exercises/test_failure.rs b/tests/test_exercises/exercises/test_failure.rs new file mode 100644 index 00000000..9dc142a4 --- /dev/null +++ b/tests/test_exercises/exercises/test_failure.rs @@ -0,0 +1,9 @@ +fn main() {} + +#[cfg(test)] +mod tests { + #[test] + fn fails() { + asset!(false); + } +} diff --git a/tests/test_exercises/exercises/test_success.rs b/tests/test_exercises/exercises/test_success.rs new file mode 100644 index 00000000..8c8a3c61 --- /dev/null +++ b/tests/test_exercises/exercises/test_success.rs @@ -0,0 +1,9 @@ +fn main() { + println!("Output from `main` function"); +} + +#[cfg(test)] +mod tests { + #[test] + fn passes() {} +} diff --git a/tests/test_exercises/info.toml b/tests/test_exercises/info.toml new file mode 100644 index 00000000..d91094c0 --- /dev/null +++ b/tests/test_exercises/info.toml @@ -0,0 +1,19 @@ +format_version = 1 + +[[exercises]] +name = "compilation_success" +test = false +hint = "" + +[[exercises]] +name = "compilation_failure" +test = false +hint = "" + +[[exercises]] +name = "test_success" +hint = "" + +[[exercises]] +name = "test_failure" +hint = "The answer to everything: 42"