@@ -58,16 +58,19 @@ fn setup_mock_project(
5858 ( zed_file, zed_test_file, bin_dir)
5959}
6060fn get_task_command_by_tag ( tag : & str ) -> String {
61- let tasks_json = fs:: read_to_string ( "languages/java/tasks.json" ) . expect ( "Failed to read tasks.json" ) ;
61+ let tasks_json =
62+ fs:: read_to_string ( "languages/java/tasks.json" ) . expect ( "Failed to read tasks.json" ) ;
6263 let tasks: Value = serde_json:: from_str ( & tasks_json) . expect ( "Failed to parse tasks.json" ) ;
6364 let tasks_array = tasks. as_array ( ) . expect ( "tasks.json is not an array" ) ;
6465
6566 for task in tasks_array {
66- if let Some ( tags) = task[ "tags" ] . as_array ( ) {
67- if tags. iter ( ) . any ( |t| t. as_str ( ) == Some ( tag) ) {
68- return task[ "command" ] . as_str ( ) . expect ( "Command is not a string" ) . to_string ( ) ;
67+ if let Some ( tags) = task[ "tags" ] . as_array ( )
68+ && tags. iter ( ) . any ( |t| t. as_str ( ) == Some ( tag) ) {
69+ return task[ "command" ]
70+ . as_str ( )
71+ . expect ( "Command is not a string" )
72+ . to_string ( ) ;
6973 }
70- }
7174 }
7275 panic ! ( "Task with tag '{}' not found" , tag) ;
7376}
@@ -87,7 +90,8 @@ impl TestProject {
8790 fs:: remove_dir_all ( & temp_dir) . unwrap ( ) ;
8891 }
8992 fs:: create_dir_all ( & temp_dir) . unwrap ( ) ;
90- let ( zed_file, zed_test_file, bin_dir) = setup_mock_project ( & temp_dir, project_type, module_path) ;
93+ let ( zed_file, zed_test_file, bin_dir) =
94+ setup_mock_project ( & temp_dir, project_type, module_path) ;
9195 let old_path = std:: env:: var ( "PATH" ) . unwrap_or_default ( ) ;
9296 let new_path = format ! ( "{}:{}" , bin_dir. to_string_lossy( ) , old_path) ;
9397 Self {
@@ -99,9 +103,11 @@ impl TestProject {
99103 }
100104 }
101105
102- fn task ( & self , tag : & str ) -> TaskRunner {
103- let command = get_task_command_by_tag ( tag)
104- . replace ( "${ZED_CUSTOM_java_outer_class_name:}" , "${ZED_CUSTOM_java_outer_class_name:-}" ) ;
106+ fn task ( & self , tag : & str ) -> TaskRunner < ' _ > {
107+ let command = get_task_command_by_tag ( tag) . replace (
108+ "${ZED_CUSTOM_java_outer_class_name:}" ,
109+ "${ZED_CUSTOM_java_outer_class_name:-}" ,
110+ ) ;
105111 TaskRunner {
106112 project : self ,
107113 command,
@@ -147,11 +153,13 @@ impl<'a> TaskRunner<'a> {
147153 self
148154 }
149155 fn method ( mut self , m : & str ) -> Self {
150- self . extra_env . push ( ( "ZED_CUSTOM_java_method_name" , m. to_string ( ) ) ) ;
156+ self . extra_env
157+ . push ( ( "ZED_CUSTOM_java_method_name" , m. to_string ( ) ) ) ;
151158 self
152159 }
153160 fn outer_class ( mut self , o : & str ) -> Self {
154- self . extra_env . push ( ( "ZED_CUSTOM_java_outer_class_name" , o. to_string ( ) ) ) ;
161+ self . extra_env
162+ . push ( ( "ZED_CUSTOM_java_outer_class_name" , o. to_string ( ) ) ) ;
155163 self
156164 }
157165
@@ -198,7 +206,8 @@ fn test_maven_single_module_command_logic() {
198206 stdout
199207 ) ;
200208 assert ! (
201- stdout_test. contains( "MVN_CALLED: clean test-compile exec:java -Dexec.mainClass=com.example.Main" ) ,
209+ stdout_test
210+ . contains( "MVN_CALLED: clean test-compile exec:java -Dexec.mainClass=com.example.Main" ) ,
202211 "Should run as single module. Got: {}" ,
203212 stdout_test
204213 ) ;
@@ -231,7 +240,7 @@ fn test_maven_multi_module_command_logic() {
231240 ) ;
232241 assert ! (
233242 stdout. contains( "-Dexec.classpathScope=runtime" ) ,
234- "Should use test classpath scope. Got: {}" ,
243+ "Should use runtime classpath scope. Got: {}" ,
235244 stdout
236245 ) ;
237246
@@ -245,7 +254,7 @@ fn test_maven_multi_module_command_logic() {
245254 "Should run only the submodule. Got: {}" ,
246255 stdout_test
247256 ) ;
248- assert ! (
257+ assert ! (
249258 stdout_test. contains( "-Dexec.classpathScope=test" ) ,
250259 "Should use test classpath scope. Got: {}" ,
251260 stdout_test
0 commit comments