Skip to content

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

Open
DYHARDx wants to merge 1 commit intoCCExtractor:masterfrom
DYHARDx:fix-comparison-offsets
Open

feat: Implement intelligent sequence matching for frame offsets in test comparison#1080
DYHARDx wants to merge 1 commit intoCCExtractor:masterfrom
DYHARDx:fix-comparison-offsets

Conversation

@DYHARDx
Copy link

@DYHARDx DYHARDx commented Mar 27, 2026

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

  • I have read and understood the contributors guide.
  • I have verified the changes locally
  • Code passes the PEP8/Pycodestyle styling checks (pycodestyle ./ --config=./.pycodestylerc)

@sonarqubecloud
Copy link

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.

[Feature Request] Improve comparison algorithm to handle frame offsets intelligently (GSoC Qualification)

1 participant