Skip to content

Commit 27999f2

Browse files
committed
Check if exercise doesn't contain tests
1 parent e74f2a4 commit 27999f2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/dev/check.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<HashSet<PathBuf>> {
9797
bail!("Didn't find any `// TODO` comment in the file `{path}`.\nYou need to have at least one such comment to guide the user.");
9898
}
9999

100-
if !exercise_info.test && file_buf.contains("#[test]\n") {
100+
let contains_tests = file_buf.contains("#[test]\n");
101+
if exercise_info.test {
102+
if !contains_tests {
103+
bail!("The file `{path}` doesn't contain any tests. If you don't want to add tests to this exercise, set `test = false` for this exercise in the `info.toml` file");
104+
}
105+
} else if contains_tests {
101106
bail!("The file `{path}` contains tests annotated with `#[test]` but the exercise `{name}` has `test = false` in the `info.toml` file");
102107
}
103108

0 commit comments

Comments
 (0)