@@ -211,7 +211,18 @@ def get_test_spec_path(case_path, test_spec):
211211 return os .path .join (case_dirname , test_spec )
212212
213213
214- def parse_suite (suite_path , parent_suite_path , options , name = None ):
214+ def get_suite_settings (name , data , upstream_settings ):
215+ for entry in data :
216+ if 'settings' in entry :
217+ if entry ['settings' ] is None :
218+ print (f"error, empty \" settings\" in suite { suite ['suite_path' ]} , invalid indent?" )
219+ sys .exit (1 )
220+
221+ vcprint (pcolor .faint , f"Suite { name } has settings: { entry ['settings' ]} " )
222+ return entry ['settings' ]
223+ return upstream_settings
224+
225+ def parse_suite (suite_path , parent_suite_path , options , settings , name = None ):
215226 suite = {}
216227 suite ['suite' ] = []
217228 suite ['result' ] = "pending"
@@ -229,14 +240,7 @@ def parse_suite(suite_path, parent_suite_path, options, name=None):
229240
230241 data = parse_yaml (suite_path )
231242
232- # Pre parse suite
233- for entry in data :
234- if 'settings' in entry :
235- if entry ['settings' ] is None :
236- print (f"error, empty \" settings\" in suite { suite ['suite_path' ]} , invalid indent?" )
237- sys .exit (1 )
238-
239- suite ['settings' ] = entry ['settings' ]
243+ settings = get_suite_settings (suite ['name' ], data , settings )
240244
241245 for entry in data :
242246 if 'suite' in entry :
@@ -248,9 +252,9 @@ def parse_suite(suite_path, parent_suite_path, options, name=None):
248252 else :
249253 opts = options .copy ()
250254 if 'name' in entry :
251- suite ['suite' ].append (parse_suite (next_suite_path , suite_path , opts , entry ['name' ]))
255+ suite ['suite' ].append (parse_suite (next_suite_path , suite_path , opts , settings , entry ['name' ]))
252256 else :
253- suite ['suite' ].append (parse_suite (next_suite_path , suite_path , opts ))
257+ suite ['suite' ].append (parse_suite (next_suite_path , suite_path , opts , settings ))
254258
255259 elif 'case' in entry :
256260 case = {}
@@ -277,14 +281,13 @@ def parse_suite(suite_path, parent_suite_path, options, name=None):
277281
278282 case ['case' ] = os .path .join (suite_dirname , entry ['case' ])
279283
280- if 'settings' in suite :
281- if 'test-spec' in suite ['settings' ]:
282- test_spec_path = get_test_spec_path (case ['case' ], suite ['settings' ]['test-spec' ])
283- if os .path .exists (test_spec_path ):
284- vcprint (pcolor .faint , f"Found test specification: { test_spec_path } for { case ['case' ]} " )
285- case ['test-spec' ] = test_spec_path
286- case ['test-spec-sha' ] = calculate_sha1sum (test_spec_path )
287- else :
284+ if 'test-spec' in settings :
285+ test_spec_path = get_test_spec_path (case ['case' ], settings ['test-spec' ])
286+ if os .path .exists (test_spec_path ):
287+ vcprint (pcolor .faint , f"Found test specification: { test_spec_path } for { case ['case' ]} " )
288+ case ['test-spec' ] = test_spec_path
289+ case ['test-spec-sha' ] = calculate_sha1sum (test_spec_path )
290+ else :
288291 vcprint (pcolor .faint , f"No test specification for { case ['case' ]} ({ test_spec_path } )" )
289292
290293 if not os .path .isfile (case ['case' ]):
@@ -718,7 +721,7 @@ def main():
718721 for filename in args .suites :
719722 fpath = os .path .join (os .getcwd (), filename )
720723 if filename .endswith ('.yaml' ):
721- cmdl ['suite' ].append (parse_suite (fpath , "command-line" , args .option ))
724+ cmdl ['suite' ].append (parse_suite (fpath , "command-line" , args .option , {} ))
722725 else :
723726 test = {}
724727 test ['case' ] = fpath
0 commit comments