@@ -852,6 +852,18 @@ async fn test_main(ctx: &mut MainContext) {
852852 // Hold the dir open for the duration of the test run.
853853 temp_projects. push ( tmp) ;
854854
855+ // Temp project for multi-file edit: root main.kcl and subdir/main.kcl.
856+ let tmp_multi = tempfile:: tempdir ( ) . expect ( "failed to create temp dir" ) ;
857+ let tmp_multi_path = tmp_multi. path ( ) . to_path_buf ( ) ;
858+ std:: fs:: create_dir_all ( tmp_multi_path. join ( "subdir" ) ) . expect ( "create subdir" ) ;
859+ std:: fs:: write ( tmp_multi_path. join ( "main.kcl" ) , "// Glorious cube\n \n sideLength = 10\n " ) . expect ( "write main.kcl" ) ;
860+ std:: fs:: write (
861+ tmp_multi_path. join ( "subdir/main.kcl" ) ,
862+ "// Glorious cylinder\n \n height = 20\n " ,
863+ )
864+ . expect ( "write subdir/main.kcl" ) ;
865+ temp_projects. push ( tmp_multi) ;
866+
855867 tests. push ( TestItem {
856868 name : "ml kcl edit reasoning on" . to_string ( ) ,
857869 args : vec ! [
@@ -894,6 +906,64 @@ async fn test_main(ctx: &mut MainContext) {
894906 ..Default :: default ( )
895907 } ) ;
896908
909+ // Multi-file project: ensure both root and subdir files are edited.
910+ tests. push ( TestItem {
911+ name : "ml kcl edit multi-file (root)" . to_string ( ) ,
912+ args : vec ! [
913+ "zoo" . to_string( ) ,
914+ "ml" . to_string( ) ,
915+ "kcl" . to_string( ) ,
916+ "edit" . to_string( ) ,
917+ "--no-reasoning" . to_string( ) ,
918+ "." . to_string( ) ,
919+ "Add" . to_string( ) ,
920+ "a" . to_string( ) ,
921+ "simple" . to_string( ) ,
922+ "cube" . to_string( ) ,
923+ "to" . to_string( ) ,
924+ "main.kcl" . to_string( ) ,
925+ "and" . to_string( ) ,
926+ "a" . to_string( ) ,
927+ "cylinder" . to_string( ) ,
928+ "to" . to_string( ) ,
929+ "subdir/main.kcl" . to_string( ) ,
930+ ] ,
931+ // Only assert presence of the root file path in stdout.
932+ want_out : "main.kcl" . to_string ( ) ,
933+ want_err : "" . to_string ( ) ,
934+ want_code : 0 ,
935+ current_directory : Some ( tmp_multi_path. clone ( ) ) ,
936+ ..Default :: default ( )
937+ } ) ;
938+ tests. push ( TestItem {
939+ name : "ml kcl edit multi-file (subdir)" . to_string ( ) ,
940+ args : vec ! [
941+ "zoo" . to_string( ) ,
942+ "ml" . to_string( ) ,
943+ "kcl" . to_string( ) ,
944+ "edit" . to_string( ) ,
945+ "--no-reasoning" . to_string( ) ,
946+ "." . to_string( ) ,
947+ "Add" . to_string( ) ,
948+ "a" . to_string( ) ,
949+ "simple" . to_string( ) ,
950+ "cube" . to_string( ) ,
951+ "to" . to_string( ) ,
952+ "main.kcl" . to_string( ) ,
953+ "and" . to_string( ) ,
954+ "a" . to_string( ) ,
955+ "cylinder" . to_string( ) ,
956+ "to" . to_string( ) ,
957+ "subdir/main.kcl" . to_string( ) ,
958+ ] ,
959+ // Only assert presence of the subdir file path in stdout.
960+ want_out : "subdir/main.kcl" . to_string ( ) ,
961+ want_err : "" . to_string ( ) ,
962+ want_code : 0 ,
963+ current_directory : Some ( tmp_multi_path. clone ( ) ) ,
964+ ..Default :: default ( )
965+ } ) ;
966+
897967 let mut config = crate :: config:: new_blank_config ( ) . unwrap ( ) ;
898968 let mut c = crate :: config_from_env:: EnvConfig :: inherit_env ( & mut config) ;
899969
0 commit comments