diff --git a/crates/cairo-lint-core/src/lib.rs b/crates/cairo-lint-core/src/lib.rs index 9a1fda88..9a87dbbf 100644 --- a/crates/cairo-lint-core/src/lib.rs +++ b/crates/cairo-lint-core/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(let_chains, is_none_or)] +#![feature(let_chains)] pub mod db; pub mod fix; pub mod lints; diff --git a/crates/cairo-lint-dev/src/main.rs b/crates/cairo-lint-dev/src/main.rs index 0c9b891e..4e6e68c5 100644 --- a/crates/cairo-lint-dev/src/main.rs +++ b/crates/cairo-lint-dev/src/main.rs @@ -2,12 +2,12 @@ use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; -fn create_new_test(lint_name: &str) -> io::Result<()> { +fn create_new_test(lint_group: &str, lint_name: &str) -> io::Result<()> { let test_content = "//! > Test name\n\n//! > cairo_code\nfn main() {\n let a: Option = \ Option::Some(1);\n}\n" .to_string(); - let test_files_dir = PathBuf::from("crates/cairo-lint-core/tests/test_files"); + let test_files_dir = PathBuf::from(format!("crates/cairo-lint-core/tests/test_files/{lint_group}")); if !test_files_dir.exists() { fs::create_dir_all(&test_files_dir)?; } @@ -26,7 +26,7 @@ fn create_new_test(lint_name: &str) -> io::Result<()> { return Ok(()); } - let new_test_entry = format!(r#"test_file!({}, "Test name");"#, lint_name); + let new_test_entry = format!(r#"test_file!({}, {}, "Test name");"#, lint_group, lint_name); let mut tests_rs_content = fs::read_to_string(tests_rs_path)?; tests_rs_content.push('\n'); @@ -39,16 +39,24 @@ fn create_new_test(lint_name: &str) -> io::Result<()> { } fn main() { - let lint_name = if let Some(arg1) = std::env::args().nth(1) { + let lint_group = if let Some(arg1) = std::env::args().nth(1) { arg1 } else { - println!("Enter the name of the lint:"); + println!("Enter the name of the lint group:"); + let mut lint_group = String::new(); + io::stdin().read_line(&mut lint_group).expect("Failed to read line"); + lint_group.trim().to_string() + }; + let lint_name = if let Some(arg1) = std::env::args().nth(2) { + arg1 + } else { + println!("Enter the name of the lint group:"); let mut lint_name = String::new(); io::stdin().read_line(&mut lint_name).expect("Failed to read line"); lint_name.trim().to_string() }; - if let Err(e) = create_new_test(&lint_name) { + if let Err(e) = create_new_test(&lint_group, &lint_name) { eprintln!("Error creating test file: {}", e); } } diff --git a/crates/cairo-lint-test-utils/src/lib.rs b/crates/cairo-lint-test-utils/src/lib.rs index 1db0fd73..43c86b70 100644 --- a/crates/cairo-lint-test-utils/src/lib.rs +++ b/crates/cairo-lint-test-utils/src/lib.rs @@ -89,7 +89,6 @@ macro_rules! test_file { new_tests.tests.insert(test_name.to_string(), new_test); } assert_eq!(formatted_diags, test.attributes["diagnostics"]); - println!("{file}"); assert_eq!(file, test.attributes["fixed"]); } }