@@ -93,6 +93,7 @@ def test_preprocess_restart_from():
9393 f"{ tmpdir } /{ TRACEBACK_FOLDER } " ,
9494 f"{ tmpdir } /{ ANA_FOLDER } /2_caprieval_analysis" ,
9595 f"{ tmpdir } /2_caprieval" ,
96+ f"{ tmpdir } /data/2_caprieval" ,
9697 ]
9798 expected_to_stay_there = [
9899 f"{ tmpdir } /1_rigidbody" ,
@@ -104,3 +105,34 @@ def test_preprocess_restart_from():
104105 assert not os .path .exists (should_not_exist )
105106 for should_exist in expected_to_stay_there :
106107 assert os .path .exists (should_exist )
108+
109+
110+ def test_preprocess_restart_from_no_folders ():
111+ """Make sure there is no issue when removing folder when not present."""
112+ with tempfile .TemporaryDirectory () as tmpdir :
113+ # Build mimic of previous run directories
114+ module_dirs = ["topoaa" , "rigidbody" , "caprieval" ]
115+ for module_index , module_name in enumerate (module_dirs ):
116+ os .makedirs (f"{ tmpdir } /data/{ module_index } _{ module_name } " )
117+ os .makedirs (f"{ tmpdir } /{ module_index } _{ module_name } " )
118+
119+ # Test restart preprocessing function
120+ restart_run .preprocess_restart_from (Path (tmpdir ), 2 )
121+
122+ expected_not_to_be_there = [
123+ f"{ tmpdir } /{ TRACEBACK_FOLDER } " ,
124+ f"{ tmpdir } /{ ANA_FOLDER } /2_caprieval_analysis" ,
125+ f"{ tmpdir } /2_caprieval" ,
126+ f"{ tmpdir } /data/2_caprieval" ,
127+ f"{ tmpdir } /{ ANA_FOLDER } " ,
128+ ]
129+ expected_to_stay_there = [
130+ f"{ tmpdir } /1_rigidbody" ,
131+ f"{ tmpdir } /data/1_rigidbody" ,
132+ f"{ tmpdir } /0_topoaa" ,
133+ f"{ tmpdir } /data/0_topoaa" ,
134+ ]
135+ for should_not_exist in expected_not_to_be_there :
136+ assert not os .path .exists (should_not_exist )
137+ for should_exist in expected_to_stay_there :
138+ assert os .path .exists (should_exist )
0 commit comments