Clean up tests

This commit is contained in:
mo8it 2024-07-25 15:12:14 +02:00
parent 3f49decce9
commit 8fec5155c7
21 changed files with 71 additions and 170 deletions

View file

@ -1,9 +1,7 @@
[workspace]
resolver = "2"
exclude = [
"tests/fixture/failure",
"tests/fixture/state",
"tests/fixture/success",
"tests/test_exercises",
"dev",
]

View file

@ -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"

View file

@ -1,6 +0,0 @@
fn main() {}
#[test]
fn passing() {
asset!(true);
}

View file

@ -1,6 +0,0 @@
fn main() {}
#[test]
fn not_passing() {
assert!(false);
}

View file

@ -1,10 +0,0 @@
format_version = 1
[[exercises]]
name = "compFailure"
test = false
hint = ""
[[exercises]]
name = "testFailure"
hint = "Hello!"

View file

@ -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"

View file

@ -1 +0,0 @@
fn main() {}

View file

@ -1,4 +0,0 @@
fn main() {}
#[test]
fn it_works() {}

View file

@ -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 = """"""

View file

@ -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"

View file

@ -1 +0,0 @@
fn main() {}

View file

@ -1,7 +0,0 @@
fn main() {}
#[test]
fn passing() {
println!("THIS TEST TOO SHALL PASS");
assert!(true);
}

View file

@ -1,10 +0,0 @@
format_version = 1
[[exercises]]
name = "compSuccess"
test = false
hint = """"""
[[exercises]]
name = "testSuccess"
hint = """"""

View file

@ -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();
}

View file

@ -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

View file

@ -0,0 +1,9 @@
fn main() {}
#[cfg(test)]
mod tests {
#[test]
fn fails() {
asset!(false);
}
}

View file

@ -0,0 +1,9 @@
fn main() {
println!("Output from `main` function");
}
#[cfg(test)]
mod tests {
#[test]
fn passes() {}
}

View file

@ -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"