Skip to content

Commit

Permalink
change error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mzuenni committed Mar 5, 2024
1 parent 61cc87d commit 42d1a81
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions bin/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent):
assert is_testcase(yaml)
assert config.COMPILED_FILE_NAME_REGEX.fullmatch(name + '.in')

# if False rule will be skipped during generation
self.ok = True
# if not None rule will be skipped during generation
self.parse_error = None

if name.endswith('.in'):
error(f'Testcase names should not end with \'.in\': {parent.path / name}')
Expand Down Expand Up @@ -436,11 +436,9 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent):
extensions.remove('.out')

if yaml is None:
intarget = self.path.parent / (self.path.name + '.in')
error(
f'Empty yaml key (Testcases must be generated not mentioned): {intarget}. Skipping.'
self.parse_error = (
f'Empty yaml key (Testcases must be generated not mentioned). Skipping.'
)
self.ok = False
return
else:
check_type('testcase', yaml, [str, dict])
Expand All @@ -462,8 +460,7 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent):
if 'generate' in yaml:
check_type('generate', yaml['generate'], str)
if len(yaml['generate']) == 0:
error(f'`generate` must not be empty. Skipping.')
self.ok = False
self.parse_error = f'`generate` must not be empty. Skipping.'
return

self.generator = GeneratorInvocation(problem, yaml['generate'])
Expand Down Expand Up @@ -513,8 +510,7 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent):
# Warn/Error for unknown keys.
for key in yaml:
if key in RESERVED_TESTCASE_KEYS:
error('Testcase must not contain reserved key {key}. Skipping.')
self.ok = False
self.parse_error = f'Testcase must not contain reserved key {key}. Skipping.'
return
if key not in KNOWN_TESTCASE_KEYS:
if config.args.action == 'generate':
Expand All @@ -537,10 +533,9 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent):
if self.hash in generator_config.rules_cache:
# This is fatal to prevent crashes later on when running generators in parallel.
# https://github.com/RagnarGrootKoerkamp/BAPCtools/issues/310
error(
f'Found identical input at {generator_config.rules_cache[self.hash]} and {self.path}. Skipping.'
self.parse_error = (
f'Found identical input at {generator_config.rules_cache[self.hash]}. Skipping.'
)
self.ok = False
return
generator_config.rules_cache[self.hash] = self.path

Expand All @@ -550,8 +545,8 @@ def generate(t, problem, generator_config, parent_bar):
t.generate_success = False

# Some early checks.
if not t.ok:
bar.done(False, f'Invalid yaml entry.')
if t.parse_error is not None:
bar.done(False, t.parse_error)
return
if t.generator and t.generator.program is None:
bar.done(False, f'Generator didn\'t build.')
Expand Down

0 comments on commit 42d1a81

Please sign in to comment.