From 39f3db900436329dcc1bfbc28f74775d1304b538 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 1 May 2015 09:51:13 +0200 Subject: [PATCH] TestTool::init: properly handle SDL::init errors So far TestTool::init was just capturing stdout and stderr of SDL::init, using stderr to check whether SDL::init failed. This, other than being fragile, misses the init errors. Switch from checking stderr to checking the actual result code of SDL::init. --- t/lib/SDL/TestTool.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t/lib/SDL/TestTool.pm b/t/lib/SDL/TestTool.pm index f5cb50a5..e674af79 100644 --- a/t/lib/SDL/TestTool.pm +++ b/t/lib/SDL/TestTool.pm @@ -20,6 +20,7 @@ sub init { my ( $self, $init ) = @_; my $stdout = ''; my $stderr = ''; + my $result = 0; if ( $init == SDL_INIT_VIDEO ) { if ( $^O !~ /win/i && !$ENV{DISPLAY} && !$ENV{SDL_VIDEODRIVER} ) { @@ -36,12 +37,12 @@ sub init { SDL::quit(); } - ($stdout, $stderr ) = capture { SDL::init($init) }; - if ( $stderr ne '' ) { + ($stdout, $stderr, $result ) = capture { SDL::init($init) }; + if ( $result != 0 ) { warn 'Init ' . $inits{$init} . ' failed with SDL error: ' . SDL::get_error() . "\nand stderr $stderr\n"; } - return !( $stderr ne '' ); + return $result == 0; } sub test_audio_open {