Skip to content

Fix syntax and logic issues in tests_to_html.py#2974

Merged
jstone-lucasfilm merged 1 commit into
AcademySoftwareFoundation:mainfrom
autodesk-forks:ppenenko/fix_tests_to_html_suffixes
Jun 12, 2026
Merged

Fix syntax and logic issues in tests_to_html.py#2974
jstone-lucasfilm merged 1 commit into
AcademySoftwareFoundation:mainfrom
autodesk-forks:ppenenko/fix_tests_to_html_suffixes

Conversation

@ppenenko

Copy link
Copy Markdown
Contributor

Summary

This PR addresses bugs in tests_to_html.py that affect the generation of HTML test reports:

  1. Robust Suffix Stripping: Replaces hardcoded string slicing lengths ([0:-8]) with Python's built-in removesuffix() method. This correctly handles variable-length language suffixes (e.g., _glsl.png which is 9 characters vs _osl.png which is 8 characters), preventing filename truncation bugs.
  2. CSS Syntax Error: Adds a trailing newline (\n) to the @media print block to prevent it from concatenating directly with the following td rule, which produces invalid CSS.
  3. Three-way Comparison Bug: Fixes a copy-paste error where path3 was joined with args.inputdir2 instead of args.inputdir3.

This fixes/addresses the following issue on the Autodesk fork:

Test plan

  • Run tests_to_html.py with variable-length language suffixes (like glsl and osl) and verify that diff image paths are correctly constructed without truncation.
  • Verify that three-way comparisons correctly locate files in inputdir3.
  • Open the generated HTML report and verify that the CSS is valid and loads correctly.

Replace hardcoded slice lengths with Python's built-in removesuffix()
to correctly support variable-length language suffixes (like _glsl.png).
Also fix a CSS formatting syntax error and a copy-paste bug that broke
three-way comparisons by using inputdir2 instead of inputdir3.
# Preserve inline background-color when printing to PDF, so transparent renders
# don't vanish into the white page.
fh.write("@media print { * { print-color-adjust: exact; -webkit-print-color-adjust: exact; } }")
fh.write("@media print { * { print-color-adjust: exact; -webkit-print-color-adjust: exact; } }\n")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS fix.

diffRms1 = diffRms2 = diffRms3 = None

if file1 and file2 and DIFF_ENABLED and args.CREATE_DIFF:
diffPath1 = fullPath1[0:-8] + "_" + args.lang1 + "-1_vs_" + args.lang2 + "-2_diff.png"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-8 is right for osl but not for glsl

file3 = file1[:-len(postFix)] + args.lang3 + ".png"
path3 = os.path.join(args.inputdir2, path1[len(args.inputdir1)+1:])
file3 = f"{file1.removesuffix(postFix)}_{args.lang3}.png"
path3 = os.path.join(args.inputdir3, path1[len(args.inputdir1)+1:])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-and-paste bug.

@jstone-lucasfilm jstone-lucasfilm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these fixes, @ppenenko!

@jstone-lucasfilm jstone-lucasfilm changed the title Fix suffix stripping, CSS syntax, and 3-way comparison in tests_to_html.py Fix syntax and logic issues in tests_to_html.py Jun 12, 2026
@jstone-lucasfilm jstone-lucasfilm merged commit 834c6a2 into AcademySoftwareFoundation:main Jun 12, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants