Bugzilla – Attachment 184127 Details for
Bug 40404
t/Test/Mock/Logger.t generates warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40404: Remove diag from t/Test/Mock/Logger.t
Bug-40404-Remove-diag-from-tTestMockLoggert.patch (text/plain), 2.40 KB, created by
Jonathan Druart
on 2025-07-16 09:09:46 UTC
(
hide
)
Description:
Bug 40404: Remove diag from t/Test/Mock/Logger.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-16 09:09:46 UTC
Size:
2.40 KB
patch
obsolete
>From eda06c3bbfedfbc84a9a4d0e82dcd0da2d0f1cb0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 16 Jul 2025 11:08:13 +0200 >Subject: [PATCH] Bug 40404: Remove diag from t/Test/Mock/Logger.t >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >t/Test/Mock/Logger.t .. 1/10 # trace: > # (No trace messages) > # debug: > # "Debug message" at /usr/share/perl/5.36/Test/Builder.pm line 374 > # info: > # (No info messages) > # warn: > # (No warn messages) > # error: > # (No error messages) > # fatal: > # (No fatal messages) >t/Test/Mock/Logger.t .. ok >All tests successful. >Files=1, Tests=10, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.40 cusr 0.07 csys = 0.50 CPU) >Result: PASS > >This one is a bit tricky: we cannot use Test::Warn to capture the output because Test::Builder->diag does not write directly to STDERR. >It has its own failure_output handle (which defaults to STDERR) but bypasses Perlâs standard layers. >--- > t/Test/Mock/Logger.t | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > >diff --git a/t/Test/Mock/Logger.t b/t/Test/Mock/Logger.t >index 1563205f8c8..015cdcae347 100755 >--- a/t/Test/Mock/Logger.t >+++ b/t/Test/Mock/Logger.t >@@ -1,5 +1,6 @@ > use Modern::Perl; >-use Test::More tests => 10; >+use Test::More tests => 11; >+use Test::NoWarnings; > use Test::Warn; > > # Module under test >@@ -132,16 +133,25 @@ subtest 'Method chaining tests' => sub { > isa_ok( $result, 't::lib::Mocks::Logger', 'Method chaining returns the logger object' ); > }; > >-# Test diag method (output capture is complex, just verify it runs) > subtest 'Diag method test' => sub { > plan tests => 1; > > $logger->clear(); > $mocked_logger->debug('Debug message'); > >- # Just make sure it doesn't throw an exception >- eval { $logger->diag(); }; >- is( $@, '', 'diag() method executed without errors' ); >+ # Capture Test::Builder diag output >+ my $diag_output = ''; >+ open my $fake_fh, '>', \$diag_output or die "Can't open: $!"; >+ >+ my $tb = Test::More->builder; >+ my $original_fh = $tb->failure_output; >+ $tb->failure_output($fake_fh); # Redirect diag output >+ >+ $logger->diag(); >+ >+ $tb->failure_output($original_fh); >+ >+ like( $diag_output, qr/debug:\n#\s*"Debug message"/xms, 'Captured diag output' ); > }; > > # Test handling of empty log buffers >-- >2.34.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 40404
: 184127