@@ -96,21 +96,25 @@ pub fn refresh_course(
9696
9797 // make_solutions
9898 log:: info!( "preparing solutions to {}" , new_solution_path. display( ) ) ;
99- for ( exercise, _) in & exercise_dirs_and_tmcprojects {
100- super :: prepare_solution (
101- & new_clone_path. join ( & exercise) ,
102- & new_solution_path. join ( & exercise) ,
103- ) ?;
99+ for ( exercise, merged_tmcproject) in & exercise_dirs_and_tmcprojects {
100+ // save merged config to solution
101+ let dest_root = new_solution_path. join ( & exercise) ;
102+ super :: prepare_solution ( & new_clone_path. join ( & exercise) , & dest_root) ?;
103+ if let Some ( merged_tmcproject) = merged_tmcproject {
104+ merged_tmcproject. save_to_dir ( & dest_root) ?;
105+ }
104106 }
105107 progress_stage ( "Prepared solutions" ) ;
106108
107109 // make_stubs
108110 log:: info!( "preparing stubs to {}" , new_stub_path. display( ) ) ;
109- for ( exercise, _) in & exercise_dirs_and_tmcprojects {
110- super :: prepare_stub (
111- & new_clone_path. join ( & exercise) ,
112- & new_stub_path. join ( & exercise) ,
113- ) ?;
111+ for ( exercise, merged_tmcproject) in & exercise_dirs_and_tmcprojects {
112+ // save merged config to stub
113+ let dest_root = new_stub_path. join ( & exercise) ;
114+ super :: prepare_stub ( & new_clone_path. join ( & exercise) , & dest_root) ?;
115+ if let Some ( merged_tmcproject) = merged_tmcproject {
116+ merged_tmcproject. save_to_dir ( & dest_root) ?;
117+ }
114118 }
115119 progress_stage ( "Prepared stubs" ) ;
116120
@@ -239,11 +243,9 @@ fn get_and_merge_tmcproject_configs(
239243 match ( & root_tmcproject, exercise_tmcproject) {
240244 ( Some ( root) , Some ( mut exercise) ) => {
241245 exercise. merge ( root. clone ( ) ) ;
242- exercise. save_to_dir ( & target_dir) ?;
243246 res. push ( ( exercise_dir, Some ( exercise) ) ) ;
244247 }
245248 ( Some ( root) , None ) => {
246- root. save_to_dir ( & target_dir) ?;
247249 res. push ( ( exercise_dir, Some ( root. clone ( ) ) ) ) ;
248250 }
249251 ( None , Some ( exercise) ) => res. push ( ( exercise_dir, Some ( exercise) ) ) ,
@@ -668,13 +670,22 @@ mod test {
668670 tpyb. save_to_dir ( & exbp_path) . unwrap ( ) ;
669671 let exercise_dirs = vec ! [ exap, exbp] ;
670672
671- get_and_merge_tmcproject_configs ( Some ( root) , temp. path ( ) , exercise_dirs) . unwrap ( ) ;
673+ let dirs_configs =
674+ get_and_merge_tmcproject_configs ( Some ( root) , temp. path ( ) , exercise_dirs) . unwrap ( ) ;
672675
673- let tpya = TmcProjectYml :: load ( & exap_path) . unwrap ( ) . unwrap ( ) ;
676+ let ( _, tpya) = & dirs_configs
677+ . iter ( )
678+ . find ( |( p, _) | p. ends_with ( "exa" ) )
679+ . unwrap ( ) ;
680+ let tpya = tpya. as_ref ( ) . unwrap ( ) ;
674681 assert_eq ! ( tpya. tests_timeout_ms, Some ( 2345 ) ) ;
675682 assert_eq ! ( tpya. fail_on_valgrind_error, Some ( true ) ) ;
676683
677- let tpyb = TmcProjectYml :: load ( & exbp_path) . unwrap ( ) . unwrap ( ) ;
684+ let ( _, tpyb) = & dirs_configs
685+ . iter ( )
686+ . find ( |( p, _) | p. ends_with ( "exb" ) )
687+ . unwrap ( ) ;
688+ let tpyb = tpyb. as_ref ( ) . unwrap ( ) ;
678689 assert_eq ! ( tpyb. tests_timeout_ms, Some ( 1234 ) ) ;
679690 assert_eq ! ( tpyb. fail_on_valgrind_error, Some ( false ) ) ;
680691 }
0 commit comments