@@ -190,3 +190,92 @@ def test_object_formatted_executables(mock_modifiers, request):
190
190
with open (exec_path ) as f :
191
191
data = f .read ()
192
192
assert ' FROM_MOD echo "Test formatted exec"' in data
193
+
194
+
195
+ def test_nested_formatted_executables_are_properly_formatted (request ):
196
+ test_config = r"""
197
+ ramble:
198
+ variables:
199
+ mpi_command: 'mpirun -n {n_ranks} -ppn {processes_per_node}'
200
+ batch_submit: '{execute_experiment}'
201
+ processes_per_node: '16'
202
+ n_threads: '1'
203
+ formatted_executables:
204
+ level_one:
205
+ prefix: 'test_l1 '
206
+ indentation: 2
207
+ join_separator: '\n'
208
+ commands:
209
+ - 'l1line1'
210
+ - 'l1line2'
211
+ - 'l1line3'
212
+ level_two:
213
+ prefix: 'test_l2 '
214
+ join_separator: '\n'
215
+ indentation: 2
216
+ commands:
217
+ - 'l2line1'
218
+ - 'l2line2'
219
+ - '{level_one}'
220
+ level_three:
221
+ prefix: 'test_l3 '
222
+ join_separator: '\n'
223
+ indentation: 2
224
+ commands:
225
+ - 'l3line1'
226
+ - '{level_two}'
227
+ applications:
228
+ basic:
229
+ workloads:
230
+ working_wl:
231
+ experiments:
232
+ simple_test:
233
+ variables:
234
+ n_nodes: 1
235
+ software:
236
+ packages: {}
237
+ environments: {}
238
+ """
239
+ workspace_name = request .node .name
240
+ with ramble .workspace .create (workspace_name ) as ws :
241
+ ws .write ()
242
+
243
+ config_path = os .path .join (ws .config_dir , ramble .workspace .config_file_name )
244
+
245
+ with open (config_path , "w+" ) as f :
246
+ f .write (test_config )
247
+
248
+ with open (os .path .join (ws .config_dir , "execute_experiment.tpl" ), "w+" ) as f :
249
+ f .write ("{level_three}\n " )
250
+ f .write ("\n \n {level_three}\n " )
251
+ ws ._re_read ()
252
+
253
+ workspace ("setup" , "--dry-run" , global_args = ["-w" , workspace_name ])
254
+
255
+ experiment_root = ws .experiment_dir
256
+ exp_dir = os .path .join (experiment_root , "basic" , "working_wl" , "simple_test" )
257
+ exp_script = os .path .join (exp_dir , "execute_experiment" )
258
+
259
+ import re
260
+
261
+ test_regexes = [
262
+ re .compile (r"^ test_l3 l3line1$" ),
263
+ re .compile (r"^ test_l3 test_l2 l2line1$" ),
264
+ re .compile (r"^ test_l3 test_l2 test_l1 l1line1$" ),
265
+ re .compile (r"^ test_l3 l3line1$" ),
266
+ ]
267
+
268
+ tests = [
269
+ False ,
270
+ False ,
271
+ False ,
272
+ False ,
273
+ ]
274
+
275
+ with open (exp_script ) as f :
276
+ for line in f .readlines ():
277
+ for idx , regex in enumerate (test_regexes ):
278
+ if regex .search (line ):
279
+ tests [idx ] = True
280
+
281
+ assert all (tests )
0 commit comments