Skip to content

Commit 39f3db9

Browse files
committed
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.
1 parent e1fbc93 commit 39f3db9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

t/lib/SDL/TestTool.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ sub init {
2020
my ( $self, $init ) = @_;
2121
my $stdout = '';
2222
my $stderr = '';
23+
my $result = 0;
2324

2425
if ( $init == SDL_INIT_VIDEO ) {
2526
if ( $^O !~ /win/i && !$ENV{DISPLAY} && !$ENV{SDL_VIDEODRIVER} ) {
@@ -36,12 +37,12 @@ sub init {
3637
SDL::quit();
3738
}
3839

39-
($stdout, $stderr ) = capture { SDL::init($init) };
40-
if ( $stderr ne '' ) {
40+
($stdout, $stderr, $result ) = capture { SDL::init($init) };
41+
if ( $result != 0 ) {
4142
warn 'Init ' . $inits{$init} . ' failed with SDL error: ' . SDL::get_error() . "\nand stderr $stderr\n";
4243
}
4344

44-
return !( $stderr ne '' );
45+
return $result == 0;
4546
}
4647

4748
sub test_audio_open {

0 commit comments

Comments
 (0)