Skip to content

Commit

Permalink
Merge pull request #280 from pinotree/init-fix
Browse files Browse the repository at this point in the history
TestTool::init: properly handle SDL::init errors
  • Loading branch information
FROGGS authored May 19, 2018
2 parents 9081d02 + 39f3db9 commit 0f2af3b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions t/lib/SDL/TestTool.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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} ) {
Expand All @@ -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 {
Expand Down

0 comments on commit 0f2af3b

Please sign in to comment.