Skip to content

Commit 9272e09

Browse files
committed
Make highlight tests fail when new syntaxes don't have fixtures
1 parent b13c4d5 commit 9272e09

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash)
88
- Prevent `--list-themes` from outputting default theme info to stdout when it is piped, see #3189 (@einfachIrgendwer0815)
99
- Rename some submodules to fix Dependabot submodule updates, see issue #3198 and PR #3201 (@victor-gp)
10+
- Make highlight tests fail when new syntaxes don't have fixtures PR #3255 (@dan-hipschman)
1011

1112
## Other
1213

tests/syntax-tests/compare_highlighted_versions.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ def compare_highlighted_versions(root_old, root_new):
1212
print(" -", root_old)
1313
print(" -", root_new)
1414
has_changes = False
15-
for path_old in glob.glob(path.join(root_old, "*", "*")):
16-
filename = path.basename(path_old)
17-
dirname = path.basename(path.dirname(path_old))
15+
# Used to check for newly added files that don't have a test
16+
unknown_files = {strip_root(p) for p in glob.glob(path.join(root_new, "*", "*"))}
1817

19-
path_new = path.join(root_new, dirname, filename)
18+
for path_old in glob.glob(path.join(root_old, "*", "*")):
19+
rel_path = strip_root(path_old)
20+
unknown_files.discard(rel_path)
21+
path_new = path.join(root_new, rel_path)
2022

21-
print("\n========== {}/{}".format(dirname, filename))
23+
print("\n========== {}".format(rel_path))
2224

2325
with open(path_old) as file_old:
2426
lines_old = file_old.readlines()
@@ -39,11 +41,21 @@ def compare_highlighted_versions(root_old, root_new):
3941
has_changes = True
4042
else:
4143
print("No changes")
42-
print()
4344

45+
for f in unknown_files:
46+
print("\n========== {}: No fixture for this language, run update.sh".format(f))
47+
has_changes = True
48+
49+
print()
4450
return has_changes
4551

4652

53+
def strip_root(p: str) -> str:
54+
filename = path.basename(p)
55+
dirname = path.basename(path.dirname(p))
56+
return path.join(dirname, filename)
57+
58+
4759
if __name__ == "__main__":
4860
parser = argparse.ArgumentParser(
4961
description="This script compares two directories that were created "

0 commit comments

Comments
 (0)