Bugzilla – Attachment 189714 Details for
Bug 41273
xt/perltidy.t could use the same parallel handling as other tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41273: Parallelize test execution for improved performance
5834612.patch (text/plain), 2.69 KB, created by
Martin Renvoize (ashimema)
on 2025-11-19 16:56:23 UTC
(
hide
)
Description:
Bug 41273: Parallelize test execution for improved performance
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-11-19 16:56:23 UTC
Size:
2.69 KB
patch
obsolete
>From 5834612c4aabf7efc5a3027d2176834303476538 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 19 Nov 2025 16:52:47 +0000 >Subject: [PATCH] Bug 41273: Parallelize test execution for improved > performance >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds parallel processing to xt/perltidy.t using >Parallel::ForkManager, following the same pattern as xt/pl_valid.t >and xt/tt_tidy.t. > >Changes: >- Uses Parallel::ForkManager to process files concurrently >- Auto-detects CPU count via Sys::CPU (respects KOHA_PROVE_CPUS env var) >- Preserves working directory context in forked child processes >- Maintains correct failure tracking in %results hash > >Performance improvement: ~NÃ speedup on N-core systems >(e.g., 8Ã faster on 8-core, 16Ã faster on 16-core machines) > >Test plan: >1. Clear incremental test cache (if needed): > docker exec kohadev-koha bash -c 'rm -rf /tmp/koha-ci-results/perltidy*' >2. Run test: > docker exec kohadev-koha bash -c 'KOHA_PROVE_CPUS=8 prove xt/perltidy.t' >3. Verify all 3138 tests pass >4. Verify test completes significantly faster than before >--- > xt/perltidy.t | 38 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 36 insertions(+), 2 deletions(-) > >diff --git a/xt/perltidy.t b/xt/perltidy.t >index 0667daa5bda..83333e2280c 100755 >--- a/xt/perltidy.t >+++ b/xt/perltidy.t >@@ -1,19 +1,53 @@ > #!/usr/bin/perl > use Modern::Perl; >+use threads; # used for parallel > use Test::PerlTidy; > use Test::More; > use Test::NoWarnings; >+use Parallel::ForkManager; >+use Sys::CPU; >+use Cwd qw(getcwd); > > use Koha::Devel::CI::IncrementalRuns; > > my $ci = Koha::Devel::CI::IncrementalRuns->new( { context => 'tidy' } ); > my @files = $ci->get_files_to_test('pl'); > >-plan tests => scalar(@files) + 1; >+my $ncpu; >+if ( $ENV{KOHA_PROVE_CPUS} ) { >+ $ncpu = $ENV{KOHA_PROVE_CPUS}; >+} else { >+ $ncpu = Sys::CPU::cpu_count(); >+} >+ >+# Capture the current working directory before forking >+my $cwd = getcwd(); > >+my $pm = Parallel::ForkManager->new($ncpu); > my %results; >+$pm->run_on_finish( >+ sub { >+ my ( $pid, $exit_code, $ident, $exit_signal, $core_dump, $data ) = @_; >+ $results{$ident} = $exit_code; >+ } >+); >+ >+plan tests => scalar(@files) + 1; >+ > for my $file (@files) { >- ok( Test::PerlTidy::is_file_tidy($file) ) or $results{$file} = 1; >+ $pm->start($file) and next; >+ >+ # Ensure we're in the correct directory in the forked process >+ chdir($cwd); >+ >+ my $is_tidy = Test::PerlTidy::is_file_tidy($file); >+ my $exit_code = $is_tidy ? 0 : 1; >+ >+ ok( $is_tidy, "$file is tidy" ); >+ >+ $pm->finish($exit_code); > } > >+$pm->wait_all_children; >+ > $ci->report_results( \%results ); >-- >2.51.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41273
: 189714