@@ -226,20 +226,15 @@ def filter_test_cases(cases: List[TypeJSON], opts: Dict[str, bool]) -> List[Type
226226 return filtered
227227
228228
229- def load_canonical (exercise : str , spec_path : Path ) -> TypeJSON :
229+ def load_canonical (exercise : str , spec_path : Path , test_opts : Dict [ str , bool ] ) -> TypeJSON :
230230 """
231231 Loads the canonical data for an exercise as a nested dictionary
232232 """
233233 full_path = spec_path / "exercises" / exercise / "canonical-data.json"
234234 with full_path .open () as f :
235235 spec = json .load (f )
236236 spec ["properties" ] = get_tested_properties (spec )
237- test_opts = load_tests_toml (exercise )
238- num_cases = len (spec ["cases" ])
239- logger .debug (f"#cases={ num_cases } " )
240237 spec ["cases" ] = filter_test_cases (spec ["cases" ], test_opts ["canonical-tests" ])
241- num_cases = len (spec ["cases" ])
242- logger .debug (f"#cases={ num_cases } after filter" )
243238 return spec
244239
245240
@@ -299,7 +294,12 @@ def generate_exercise(env: Environment, spec_path: Path, exercise: Path, check:
299294 plugins_module = importlib .util .module_from_spec (plugins_spec )
300295 sys .modules [plugins_name ] = plugins_module
301296 plugins_spec .loader .exec_module (plugins_module )
302- spec = load_canonical (slug , spec_path )
297+ try :
298+ test_opts = load_tests_toml (slug )
299+ except FileNotFoundError :
300+ logger .error (f"{ slug } : tests.toml not found; please run canonical_data_syncer" )
301+ return False
302+ spec = load_canonical (slug , spec_path , test_opts )
303303 additional_tests = load_additional_tests (slug )
304304 spec ["additional_cases" ] = additional_tests
305305 template_path = Path (slug ) / ".meta" / "template.j2"
0 commit comments