@@ -96,21 +96,25 @@ pub fn refresh_course(
96
96
97
97
// make_solutions
98
98
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
+ }
104
106
}
105
107
progress_stage ( "Prepared solutions" ) ;
106
108
107
109
// make_stubs
108
110
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
+ }
114
118
}
115
119
progress_stage ( "Prepared stubs" ) ;
116
120
@@ -239,11 +243,9 @@ fn get_and_merge_tmcproject_configs(
239
243
match ( & root_tmcproject, exercise_tmcproject) {
240
244
( Some ( root) , Some ( mut exercise) ) => {
241
245
exercise. merge ( root. clone ( ) ) ;
242
- exercise. save_to_dir ( & target_dir) ?;
243
246
res. push ( ( exercise_dir, Some ( exercise) ) ) ;
244
247
}
245
248
( Some ( root) , None ) => {
246
- root. save_to_dir ( & target_dir) ?;
247
249
res. push ( ( exercise_dir, Some ( root. clone ( ) ) ) ) ;
248
250
}
249
251
( None , Some ( exercise) ) => res. push ( ( exercise_dir, Some ( exercise) ) ) ,
@@ -668,13 +670,22 @@ mod test {
668
670
tpyb. save_to_dir ( & exbp_path) . unwrap ( ) ;
669
671
let exercise_dirs = vec ! [ exap, exbp] ;
670
672
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 ( ) ;
672
675
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 ( ) ;
674
681
assert_eq ! ( tpya. tests_timeout_ms, Some ( 2345 ) ) ;
675
682
assert_eq ! ( tpya. fail_on_valgrind_error, Some ( true ) ) ;
676
683
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 ( ) ;
678
689
assert_eq ! ( tpyb. tests_timeout_ms, Some ( 1234 ) ) ;
679
690
assert_eq ! ( tpyb. fail_on_valgrind_error, Some ( false ) ) ;
680
691
}
0 commit comments