From: Kartik Thakore Date: Tue, 10 Nov 2009 02:46:13 +0000 (-0500) Subject: For the last time negative test for failing soundcards X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=40ccf32ccda303d82ded14cdee426adb8808ab31;p=sdlgit%2FSDL_perl.git For the last time negative test for failing soundcards --- diff --git a/Build.PL b/Build.PL index 2f8c29a..00964f7 100644 --- a/Build.PL +++ b/Build.PL @@ -250,7 +250,7 @@ my $build = SDL::Build->new( build_requires => { 'Test::Simple' => '0.47', - 'File::Spec' => '0', + 'IO::CaptureOutput' => '0', 'Test::Most' => '0.21', }, build_recommends => diff --git a/t/core_mixchunk.t b/t/core_mixchunk.t index 0e4285f..ef73a3e 100644 --- a/t/core_mixchunk.t +++ b/t/core_mixchunk.t @@ -5,22 +5,28 @@ use SDL; use SDL::Mixer::MixChunk; use Test::More; use File::Spec; +use IO::CaptureOutput qw(capture); sub test_audio { - my $devnull = File::Spec->devnull(); - `perl -e "use lib '../'; use SDL; SDL::init(SDL_INIT_AUDIO)" 2>$devnull`; - return ($? >> 8 ); + my $stdout = 0 ; + my $stderr = 0 ; + capture { SDL::init(SDL_INIT_AUDIO) } \$stdout, \$stderr; + SDL::quit(); + return ($stderr == 0 ); } -if ( test_audio != 1) + +if ( test_audio ) { plan ( skip_all => 'Failed to init sound' ); } -else { - SDL::init(SDL_INIT_AUDIO); - plan( tests => 3 ); -} +elsif(SDL::init(SDL_INIT_AUDIO) >= 0) + { plan( tests => 3 ) } +else + { + plan ( skip_all => 'Failed to init sound' ); + } diff --git a/t/core_mixmusic.t b/t/core_mixmusic.t index a4817bf..36846c2 100644 --- a/t/core_mixmusic.t +++ b/t/core_mixmusic.t @@ -4,23 +4,27 @@ use warnings; use SDL; use SDL::Mixer::MixMusic; use Test::More; -use File::Spec; +use IO::CaptureOutput qw(capture); sub test_audio { - my $devnull = File::Spec->devnull(); - `perl -e "use lib '../'; use SDL; SDL::init(SDL_INIT_AUDIO)" 2>$devnull`; - return ($? >> 8 ); + my $stdout = 0 ; + my $stderr = 0 ; + capture { SDL::init(SDL_INIT_AUDIO) } \$stdout, \$stderr; + SDL::quit(); + return ($stderr == 0 ); } -if ( test_audio != 1) +if ( test_audio ) { plan ( skip_all => 'Failed to init sound' ); } -else { - SDL::init(SDL_INIT_AUDIO); - plan( tests => 3 ); -} +elsif(SDL::init(SDL_INIT_AUDIO) >= 0) + { plan( tests => 3 ) } +else + { + plan ( skip_all => 'Failed to init sound' ); + } is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), 0, 'MixOpenAudio passed' );