Skip to content

Commit

Permalink
[generate] TestcaseRule.generate().copy_generated(): only keep visual…
Browse files Browse the repository at this point in the history
…izer output when .in/.ans did not change
  • Loading branch information
mpsijm committed Jul 17, 2024
1 parent 1558282 commit f85a5bc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bin/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,8 @@ def generate_visualization():
return True

def copy_generated():
identical_exts = set()

for ext in config.KNOWN_DATA_EXTENSIONS:
source = infile.with_suffix(ext)
target = target_infile.with_suffix(ext)
Expand All @@ -984,7 +986,7 @@ def copy_generated():
if target.is_file():
if source.read_bytes() == target.read_bytes() and not target.is_symlink():
# identical -> skip
pass
identical_exts.add(ext)
else:
# different -> overwrite
generator_config.remove(target)
Expand All @@ -995,8 +997,16 @@ def copy_generated():
shutil.copy(source, target, follow_symlinks=True)
bar.log(f'NEW: {target.name}')
elif target.is_file():
if config.args.no_visualizer and ext in config.KNOWN_VISUALIZER_EXTENSIONS:
continue # Do not remove output of visualizer when running with --no-visualizer
if (
config.args.no_visualizer
and ext in config.KNOWN_VISUALIZER_EXTENSIONS
and '.in' in identical_exts
and '.ans' in identical_exts
):
# When running with --no-visualizer and .in/.ans files did not change,
# do not remove output of visualizer.
# This is useful for when a user/CI has a clean cache (e.g. after a reboot).
continue
# Target exists but source wasn't generated -> remove it
generator_config.remove(target)
bar.log(f'REMOVED: {target.name}')
Expand Down

0 comments on commit f85a5bc

Please sign in to comment.