sample-platform icon indicating copy to clipboard operation
sample-platform copied to clipboard

feat: Implement intelligent sequence matching for frame offsets in test comparison

Open DYHARDx opened this issue 8 months ago • 1 comments

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-td empty 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)

DYHARDx avatar Mar 27 '26 05:03 DYHARDx