CCExtractor / CCExtractor/sample-platform
[Feature Request] Improve comparison algorithm to handle frame offsets intelligently (GSoC Qualification)
- Vorherrschende Sprache
- Python
- Sterne
- 30
- Forks
- 85
- Ø Merge
- 6 T. 21 Std.
- Gemergte PRs (30 T.)
- 12
Beschreibung
### Context
According to the "Sample Platform NG" GSoC project brief, one of the major goals is to improve the comparison algorithm. Currently, the comparison system is quite rigid, evaluating results strictly line-by-line. If a single frame (subtitle frame) is missing or slightly offset in the output, it causes a chain reaction where all subsequent frames are treated as a mismatch, causing the entire test to fail unnecessarily.
### Current Behavior
In [mod_test/nicediff/diff.py](cci:7://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:0:0-0:0) (around line 144 to 157 in [get_html_diff](cci:1://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:123:0-217:15)), the logic iterates through `use` length and compares `test_correct_lines[line] == test_res_lines[line]`.
This naive 1-to-1 index matching means that if `test_res_lines` drops line index 5, then index 6 of the result is compared against index 5 of the expected output, index 7 vs index 6, leading to a 100% mismatch from that point onwards.
### Expected Behavior
The comparison algorithm should be smart enough to detect insertions, deletions, and offsets. If a single frame is dropped, the diff should highlight *only* that specific dropped frame as an error, and successfully resync/align the remaining lines that match.
### Proposed Solution
I propose rewriting the core logic in [mod_test/nicediff/diff.py](cci:7://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:0:0-0:0) (specifically [get_html_diff](cci:1://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:123:0-217:15) and the event generation) to leverage a Sequence Matching algorithm (such as Python's built-in `difflib.SequenceMatcher` or a similar longest-common-subsequence approach).
This will allow us to:
1. Identify the exact opcode (`replace`, `delete`, `insert`, `equal`) for block ranges.
2. Gracefully handle offsets so the rest of the valid output remains marked as "Passed".
3. Render a much more accurate and readable HTML diff for the developers debugging the test suite.
### Goal
I am applying for GSoC for this project under the mentorship of @carlos.fernandez and @canihavesomecoffee. I would love to take this up as my qualification task and submit a PR fixing this core comparison logic. Let me know if I have the green light to proceed with this!
Beitragsleitfaden
Rechercherichtung
Beginne in mod_test/nicediff/diff.py, insbesondere bei get_html_diff um die Zeilen 123–217 und seiner Ereigniserzeugung. Lies nach, wie der aktuelle zeilenweise Vergleich test_correct_lines und test_res_lines verwendet, und definiere dann das Verhalten für Einfüge-, Lösch-, Ersetzungs- und gleiche Bereiche. Als abgeschlossen gilt die Aufgabe, wenn verworfene oder verschobene Frames isoliert werden, während übereinstimmende spätere Zeilen weiterhin als bestanden markiert werden und der HTML-Diff korrekt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- testing-qa
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100