From 2cdd61294f0d9a53775ee24ad76435bec8a21e60 Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Mon, 11 Nov 2019 13:38:24 +0100 Subject: feat: improve `watch` execution mode The `watch` command now requires user action to move to the next exercise. BREAKING CHANGE: this changes the behavior of `watch`. --- tests/fixture/state/finished_exercise.rs | 0 tests/fixture/state/pending_exercise.rs | 7 +++++++ tests/integration_tests.rs | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/fixture/state/finished_exercise.rs create mode 100644 tests/fixture/state/pending_exercise.rs (limited to 'tests') diff --git a/tests/fixture/state/finished_exercise.rs b/tests/fixture/state/finished_exercise.rs new file mode 100644 index 0000000..e69de29 diff --git a/tests/fixture/state/pending_exercise.rs b/tests/fixture/state/pending_exercise.rs new file mode 100644 index 0000000..f579d0b --- /dev/null +++ b/tests/fixture/state/pending_exercise.rs @@ -0,0 +1,7 @@ +// fake_exercise + +// I AM NOT DONE + +fn main() { + +} diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 3acaf90..897cd2a 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1,4 +1,7 @@ use assert_cmd::prelude::*; +use glob::glob; +use std::fs::File; +use std::io::Read; use std::process::Command; #[test] @@ -105,3 +108,20 @@ fn run_single_test_no_exercise() { .assert() .code(1); } + +#[test] +fn all_exercises_require_confirmation() { + for exercise in glob("exercises/**/*.rs").unwrap() { + let path = exercise.unwrap(); + let source = { + let mut file = File::open(&path).unwrap(); + let mut s = String::new(); + file.read_to_string(&mut s).unwrap(); + s + }; + source.matches("// I AM NOT DONE").next().expect(&format!( + "There should be an `I AM NOT DONE` annotation in {:?}", + path + )); + } +} -- cgit v1.2.3