feat: Implement intelligent sequence matching for frame offsets in test comparison
Description
This PR addresses a core requirement mentioned in the "Sample Platform NG" GSoC brief: improving the regression test comparison algorithm to gracefully handle frame offsets.
Previously, mod_test/nicediff/diff.py evaluated the actual vs. expected test results strictly line-by-line (1-to-1 index matching). If a single subtitle frame was dropped or offset, it triggered a chain reaction where all subsequent frames were incorrectly labeled as a mismatch, causing the entire test to fail unnecessarily.
This PR refactors get_html_diff to leverage Python's built-in difflib.SequenceMatcher.
Changes Made
- Added
import difflib - Replaced the naive for loop matched-index comparison in get_html_diff with
sm.get_opcodes(). - The logic now properly identifies opcodes (
replace,insert,delete,equal) and parses the text into HTML blocks. - Missing frames are explicitly rendered as deletions or insertions (
diff-table-tdempty rows mapping), ensuring the rest of the output resyncs and reads accurately without a false-negative cascading failure!
Related Issue
Fixes #1079
GSoC Context
I am submitting this PR as my qualification task for GSoC (Sample Platform NG project).
Checklist before review
- [x] I have read and understood the contributors guide.
- [x] I have verified the changes locally
- [x] Code passes the PEP8/Pycodestyle styling checks (
pycodestyle ./ --config=./.pycodestylerc)
Quality Gate passed
Issues
3 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code