From 30eb54b5cafd78eca990bc8067e6cf18b2712b7c Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Thu, 13 Jun 2024 00:43:21 -0400 Subject: [PATCH] Add `config_proc_macro` to system tests Also formats unforamatted files in the crate. --- config_proc_macro/src/attrs.rs | 6 +++++- src/test/mod.rs | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config_proc_macro/src/attrs.rs b/config_proc_macro/src/attrs.rs index d8de9aae088..e7534b813d7 100644 --- a/config_proc_macro/src/attrs.rs +++ b/config_proc_macro/src/attrs.rs @@ -68,7 +68,11 @@ fn get_name_value_str_lit(attr: &syn::Attribute, name: &str) -> Option { match &attr.meta { syn::Meta::NameValue(syn::MetaNameValue { path, - value: syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(lit_str), .. }), + value: + syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Str(lit_str), + .. + }), .. }) if path.is_ident(name) => Some(lit_str.value()), _ => None, diff --git a/src/test/mod.rs b/src/test/mod.rs index d567a1b8e4e..7c563801c32 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -391,12 +391,24 @@ fn self_tests() { files.push(path); } // for crates that need to be included but lies outside src - let external_crates = vec!["check_diff"]; + let external_crates = vec!["check_diff", "config_proc_macro"]; for external_crate in external_crates { let mut path = PathBuf::from(external_crate); path.push("src"); - path.push("main.rs"); - files.push(path); + let directory = fs::read_dir(&path).unwrap(); + let search_files = directory.filter_map(|file| { + file.ok().and_then(|f| { + let name = f.file_name(); + if matches!(name.as_os_str().to_str(), Some("main.rs" | "lib.rs")) { + Some(f.path()) + } else { + None + } + }) + }); + for file in search_files { + files.push(file); + } } files.push(PathBuf::from("src/lib.rs"));