summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-17 18:59:40 +0200
committermo8it <mo8it@proton.me>2024-04-17 18:59:40 +0200
commitd42a6e741564313460fceb055d0aebe599cbe232 (patch)
treefe1ad2b683befa022cb4e1d30bb3f9a83420a684 /src/dev
parentb9167e9299bfe7c644cdbc2f6e933873f06b1c3f (diff)
Print the path of the missing file
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/check.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/dev/check.rs b/src/dev/check.rs
index ac2c603..2c48f0e 100644
--- a/src/dev/check.rs
+++ b/src/dev/check.rs
@@ -17,6 +17,7 @@ fn forbidden_char(input: &str) -> Option<char> {
fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<PathBuf>> {
let mut names = hashbrown::HashSet::with_capacity(info_file.exercises.len());
let mut paths = hashbrown::HashSet::with_capacity(info_file.exercises.len());
+
for exercise_info in &info_file.exercises {
if let Some(c) = forbidden_char(&exercise_info.name) {
bail!(
@@ -49,6 +50,7 @@ fn check_exercise_dir_files(
info_file_paths: hashbrown::HashSet<PathBuf>,
) -> Result<hashbrown::HashSet<String>> {
let mut names = hashbrown::HashSet::with_capacity(info_file.exercises.len());
+
for entry in read_dir("exercises").context("Failed to open the `exercises` directory")? {
let entry = entry.context("Failed to read the `exercises` directory")?;
@@ -89,8 +91,11 @@ fn check_exercise_dir_files(
bail!("`{}` is expected to be an exercise file corresponding to some exercise in `info.toml`", path.display());
}
+ // The file name must be valid Unicode with the `.rs` extension
+ // because it is part of the info file paths.
let file_name = file_name.to_string_lossy();
- names.insert(file_name[..file_name.len() - 3].to_string());
+ let file_name_without_rs_extension = file_name[..file_name.len() - 3].to_string();
+ names.insert(file_name_without_rs_extension);
}
}
@@ -112,10 +117,7 @@ fn check_info_file(info_file: &InfoFile) -> Result<()> {
if names_in_exercises_dir.len() != info_file.exercises.len() {
for exercise_info in &info_file.exercises {
if !names_in_exercises_dir.contains(&exercise_info.name) {
- bail!(
- "No exercise file found for the exercise `{}`",
- exercise_info.name,
- );
+ bail!("The file `{}` is missing", exercise_info.path());
}
}
}
@@ -178,7 +180,6 @@ fn check_cargo_toml(
pub fn check() -> Result<()> {
let info_file = InfoFile::parse()?;
-
check_info_file(&info_file)?;
if DEVELOPING_OFFICIAL_RUSTLINGS {