Skip to content

Commit

Permalink
tests/test_codespell.py: improve output diagnostics.
Browse files Browse the repository at this point in the history
Put codespell args and input files on separate lines; makes output easier to
read if test fails.
  • Loading branch information
julian-smith-artifex-com committed Aug 9, 2024
1 parent f0b5017 commit 9307196
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/test_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ def test_codespell():
''')
skips = skips.strip().replace('\n', ',')

command = f'cd {root} && codespell --skip {shlex.quote(skips)} --count'
command += f' --ignore-words-list re-use,flate,thirdparty'
command = textwrap.dedent(f'''
cd {root} && codespell
--skip {shlex.quote(skips)}
--ignore-words-list re-use,flate,thirdparty
''')

sys.path.append(root)
try:
Expand All @@ -56,11 +59,16 @@ def test_codespell():

for p in git_files:
_, ext = os.path.splitext(p)
if ext in ('.png', '.pdf'):
if ext in ('.png', '.pdf', '.jpg', '.svg'):
pass
else:
command += f' {p}'
command += f' {p}\n'

print(f'test_codespell(): Running: {command}')
if platform.system() != 'Windows':
command = command.replace('\n', ' \\\n')
# Don't print entire command because very long, and will be displayed
# anyway if there is an error.
#print(f'test_codespell(): Running: {command}')
print(f'Running codespell.')
subprocess.run(command, shell=1, check=1)
print('test_codespell(): codespell succeeded.')

0 comments on commit 9307196

Please sign in to comment.