Skip to content

Commit

Permalink
simulate the error case when system() returns -1
Browse files Browse the repository at this point in the history
  • Loading branch information
gugod committed Jul 27, 2022
1 parent e918577 commit 6b6be6d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions t/error-http_download-exec-error.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env perl
use strict;
use warnings;

use Test::More import => [ qw( done_testing like subtest ) ];
use File::Temp qw( tempdir );

BEGIN {
*CORE::GLOBAL::system = sub {
return $? = -1
};
}

use App::Perlbrew::Path;
use App::Perlbrew::HTTP qw(http_download);

local $ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );

subtest "The exit status code of curl", sub {
my $error = http_download( "https://example.com/whatever.tar.gz",
App::Perlbrew::Path->new($App::perlbrew::PERLBREW_ROOT)->child("whatever.tar.gz") );

like $error, qr/^ERROR: Failed to execute the command/;
};

done_testing;

0 comments on commit 6b6be6d

Please sign in to comment.