Bug 39741

Summary: xt/author/valid-templates.t should setting dirs to skip
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Test SuiteAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: Signed Off --- QA Contact: Jonathan Druart <jonathan.druart>
Severity: enhancement    
Priority: P5 - low CC: david, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 38340    
Bug Blocks:    
Attachments: Bug 39741: Make valid-templates.t handle dirs
Bug 39741: Make valid-templates.t handle dirs

Description Tomás Cohen Arazi (tcohen) 2025-04-24 14:21:14 UTC
Bug 38340 added a bunch of form includes that all live in the same dir, to the exclusion list.

We should refactor those tests so one can set a directory for exclusion instead of listing each file.
Comment 1 Tomás Cohen Arazi (tcohen) 2025-04-24 14:49:27 UTC
Created attachment 181462 [details] [review]
Bug 39741: Make valid-templates.t handle dirs

This patch changes the regex so it doesn't expect the exclusion
parameters to only be files but accept directories too.

The risk of this is we might at some point catch more than we want.

I don't think it is worth spending more time in it, though.

To test:
1. Run:
   $ ktd --shell
  k$ prove xt/author/valid-templates.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass! We don't need to list each individual file
anymore and it will still work!
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 Tomás Cohen Arazi (tcohen) 2025-04-24 14:50:24 UTC
Another option could be to properly refactor the parameters so the exclusion lists are two: files and dirs. And each use a different regex.

I leave my 2 cents here.
Comment 3 David Nind 2025-04-25 22:12:47 UTC
Created attachment 181559 [details] [review]
Bug 39741: Make valid-templates.t handle dirs

This patch changes the regex so it doesn't expect the exclusion
parameters to only be files but accept directories too.

The risk of this is we might at some point catch more than we want.

I don't think it is worth spending more time in it, though.

To test:
1. Run:
   $ ktd --shell
  k$ prove xt/author/valid-templates.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass! We don't need to list each individual file
anymore and it will still work!
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2025-04-25 22:15:54 UTC
Testing notes (using KTD):
1. Tests pass before and after the patch.
2. Getting lots of output with these lines - not sure whether this is a good or bad thing:
   - Argument "" isn't numeric in numeric gt (>)...
   - # excluding template /kohadevbox/koha/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc because it cannot stand on its own