Bug 41274

Summary: Incremental test runs not properly skipping Schema files
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: blocker    
Priority: P5 - low CC: jonathan.druart, lucas
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41274: Koha::Devel::Files - Fix exception filtering in incremental mode
Bug 41274: Remove range parameter from ls_perl_files
Bug 41274: Remove the exceptions from git range
Bug 41274: Remove exceptions from files listed in the result repo

Description Martin Renvoize (ashimema) 2025-11-19 17:09:55 UTC
The incremental test runs Koha::Devel::Files module is failing to skip the DBIx::Class generated Schema files
Comment 1 Martin Renvoize (ashimema) 2025-11-19 17:11:00 UTC
Created attachment 189716 [details] [review]
Bug 41274: Koha::Devel::Files - Fix exception filtering in incremental mode

This patch fixes two bugs in the file exception filtering logic that
caused generated files (like Koha/Schema/Result/*) to not be excluded
properly when running in incremental/CI mode.

Bug #1: Incorrect array assignment
Lines 173 and 204 were assigning an arrayref as a single element
instead of dereferencing it:
  my @exception_files = $exceptions->{...};  # Wrong: creates array with 1 element (arrayref)
  my @exception_files = @{ $exceptions->{...} };  # Correct: dereferences to array

Bug #2: Pattern matching not supported
array_minus() only performs exact string matches, so patterns like
"Koha/Schema/Result" would not match "Koha/Schema/Result/Aqbasket.pm".

The fix:
- Properly dereferences exception patterns array
- Replaces array_minus with grep + regex pattern matching
- Uses /^\Q$_\E/ to match file paths starting with exception patterns
- Removes now-unused Array::Utils dependency

This ensures consistent behavior between:
- Non-incremental mode: Uses git ls-files with :(exclude) patterns
- Incremental mode: Now uses equivalent pattern matching

Test plan:
1. Run tests locally (non-incremental): prove xt/perltidy.t
2. Verify Schema files are excluded
3. Run in CI (incremental mode) with Schema file changes
4. Verify Schema files are now correctly excluded (previously failing)
Comment 2 Jonathan Druart 2025-11-20 13:52:48 UTC
Related to https://gitlab.com/koha-community/koha-testing-docker/-/merge_requests/562

Without we cannot test locally.
Comment 3 Jonathan Druart 2025-11-20 14:01:48 UTC
Created attachment 189776 [details] [review]
Bug 41274: Remove range parameter from ls_perl_files

It's not used.
Comment 4 Jonathan Druart 2025-11-20 14:02:01 UTC
Created attachment 189777 [details] [review]
Bug 41274: Remove the exceptions from git range

When listing the files from a git range we want to remove the exception
files from that list
Comment 5 Jonathan Druart 2025-11-20 14:02:13 UTC
Created attachment 189778 [details] [review]
Bug 41274: Remove exceptions from files listed in the result repo

IF we have pushed some files that should have been excluded from the
tests but have been processed previously and failed, we should skip it
the next build anyway