From 5d0a044cb6ada446dbe5ff5ef9c55a6f993ce938 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jul 2025 11:24:17 +0200 Subject: [PATCH] Bug 18772: Remove warnings from t/ImportBatch.t Use of uninitialized value in concatenation (.) or string at /usr/local/share/perl/5.20.2/MARC/File/XML.pm line 399, <__ANONIO__> chunk 1. Those are 2 warnings coming from MARC::File::XML when called with invalid XML. We should not use Test::Warn as they are not expected and that may be fixed upstream. --- t/ImportBatch.t | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/t/ImportBatch.t b/t/ImportBatch.t index 749f9b06408..0258e4e5c3b 100755 --- a/t/ImportBatch.t +++ b/t/ImportBatch.t @@ -17,11 +17,12 @@ use Modern::Perl; +use Test::More tests => 4; +use Test::NoWarnings; use File::Temp qw|tempfile|; use MARC::Field; use MARC::File::XML; use MARC::Record; -use Test::More tests => 3; use t::lib::Mocks; BEGIN { @@ -55,11 +56,28 @@ subtest 'RecordsFromMARCXMLFile' => sub { my ( $errors, $recs ); my $file = create_file( { whitespace => 1, format => 'marcxml' } ); - ( $errors, $recs ) = C4::ImportBatch::RecordsFromMARCXMLFile( $file, 'UTF-8' ); + { + # Ignore the following warning + # Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/MARC/File/XML.pm line 399, <__ANONIO__> chunk 1. + # We do not want to expect it (using Test::Warn): it is a bug from MARC::File::XML + local $SIG{__WARN__} = sub { }; + my $dup_err; + local *STDERR; + open STDERR, ">>", \$dup_err; + ( $errors, $recs ) = C4::ImportBatch::RecordsFromMARCXMLFile( $file, 'UTF-8' ); + close STDERR; + } is( @$recs, 0, 'No records from empty marcxml file' ); $file = create_file( { garbage => 1, format => 'marcxml' } ); - ( $errors, $recs ) = C4::ImportBatch::RecordsFromMARCXMLFile( $file, 'UTF-8' ); + { + local $SIG{__WARN__} = sub { }; + my $dup_err; + local *STDERR; + open STDERR, ">>", \$dup_err; + ( $errors, $recs ) = C4::ImportBatch::RecordsFromMARCXMLFile( $file, 'UTF-8' ); + close STDERR; + } is( @$recs, 0, 'Garbage returns no records' ); $file = create_file( { two => 1, format => 'marcxml' } ); -- 2.34.1