From 9272e09058a89fd64cb051bf6972ff6cb2d2d83f Mon Sep 17 00:00:00 2001 From: Dan Hipschman <48698358+dan-hipschman@users.noreply.github.com> Date: Tue, 1 Apr 2025 12:58:00 -0700 Subject: [PATCH] Make highlight tests fail when new syntaxes don't have fixtures --- CHANGELOG.md | 1 + .../compare_highlighted_versions.py | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8c59964..9804d51c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash) - Prevent `--list-themes` from outputting default theme info to stdout when it is piped, see #3189 (@einfachIrgendwer0815) - Rename some submodules to fix Dependabot submodule updates, see issue #3198 and PR #3201 (@victor-gp) +- Make highlight tests fail when new syntaxes don't have fixtures PR #3255 (@dan-hipschman) ## Other diff --git a/tests/syntax-tests/compare_highlighted_versions.py b/tests/syntax-tests/compare_highlighted_versions.py index 9cf67e46..ad142e9f 100755 --- a/tests/syntax-tests/compare_highlighted_versions.py +++ b/tests/syntax-tests/compare_highlighted_versions.py @@ -12,13 +12,15 @@ def compare_highlighted_versions(root_old, root_new): print(" -", root_old) print(" -", root_new) has_changes = False + # Used to check for newly added files that don't have a test + unknown_files = {strip_root(p) for p in glob.glob(path.join(root_new, "*", "*"))} + for path_old in glob.glob(path.join(root_old, "*", "*")): - filename = path.basename(path_old) - dirname = path.basename(path.dirname(path_old)) + rel_path = strip_root(path_old) + unknown_files.discard(rel_path) + path_new = path.join(root_new, rel_path) - path_new = path.join(root_new, dirname, filename) - - print("\n========== {}/{}".format(dirname, filename)) + print("\n========== {}".format(rel_path)) with open(path_old) as file_old: lines_old = file_old.readlines() @@ -39,11 +41,21 @@ def compare_highlighted_versions(root_old, root_new): has_changes = True else: print("No changes") - print() + for f in unknown_files: + print("\n========== {}: No fixture for this language, run update.sh".format(f)) + has_changes = True + + print() return has_changes +def strip_root(p: str) -> str: + filename = path.basename(p) + dirname = path.basename(path.dirname(p)) + return path.join(dirname, filename) + + if __name__ == "__main__": parser = argparse.ArgumentParser( description="This script compares two directories that were created "