Skip to content

Commit

Permalink
Merge pull request #816 from gugod/remove-io-all
Browse files Browse the repository at this point in the history
Remove IO::All from the list of test dependencies
  • Loading branch information
gugod authored Sep 7, 2024
2 parents 8d48b57 + efe0b71 commit 8a94cef
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 20 deletions.
1 change: 0 additions & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"test" : {
"requires" : {
"File::Which" : "1.21",
"IO::All" : "0.51",
"Path::Class" : "0.33",
"Test2::Plugin::IOEvents" : "0.001001",
"Test2::Plugin::NoWarnings" : "0.10",
Expand Down
1 change: 0 additions & 1 deletion META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ author:
- 'Kang-min Liu C<< <[email protected]> >>'
build_requires:
File::Which: '1.21'
IO::All: '0.51'
Path::Class: '0.33'
Test2::Plugin::IOEvents: '0.001001'
Test2::Plugin::NoWarnings: '0.10'
Expand Down
1 change: 0 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ requires 'ExtUtils::MakeMaker' => '7.22';
on test => sub {
requires 'File::Temp' => '0.2304';
requires 'File::Which' => '1.21';
requires 'IO::All' => '0.51';
requires 'Path::Class' => '0.33';
requires 'Test2::V0' => '0.000163';
requires 'Test2::Plugin::NoWarnings' => '0.10';
Expand Down
8 changes: 6 additions & 2 deletions t/12.destdir.t
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!perl
use Test2::V0;
use Capture::Tiny qw/capture/;
use IO::All;
use App::perlbrew;
use File::Temp qw( tempdir );

use FindBin;
use lib $FindBin::Bin;
use PerlbrewTestHelpers qw( write_file );

$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
Expand Down Expand Up @@ -47,7 +50,8 @@ sub App::perlbrew::do_install_release {
$root->child("perls", $name, "bin")->mkpath;

my $perl = $root->child("perls", $name, "bin")->child("perl");
io($perl)->print("#!/bin/sh\nperl \"\$@\";\n");

write_file($perl, "#!/bin/sh\nperl \"\$@\";\n");
chmod 0755, $perl;

# fake the install
Expand Down
9 changes: 6 additions & 3 deletions t/12.sitecustomize.t
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!perl
use Test2::V0;
use Capture::Tiny qw/capture/;
use IO::All;
use App::perlbrew;
use File::Temp qw( tempdir );

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
use PerlbrewTestHelpers qw(write_file);

$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
Expand Down Expand Up @@ -44,7 +47,7 @@ sub App::perlbrew::do_install_release {
$root->child("perls", $name, "bin")->mkpath;

my $perl = $root->child("perls", $name, "bin")->child("perl");
io($perl)->print("#!/bin/sh\nperl \"\$@\";\n");
write_file($perl, "#!/bin/sh\nperl \"\$@\";\n");
chmod 0755, $perl;

# fake the install
Expand Down
23 changes: 22 additions & 1 deletion t/PerlbrewTestHelpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use Test2::V0;
use Test2::Plugin::IOEvents;

use Exporter 'import';
our @EXPORT_OK = qw(stderr_from stderr_is stderr_like stdout_from stdout_is stdout_like);
our @EXPORT_OK = qw(
read_file write_file
stderr_from stderr_is stderr_like
stdout_from stdout_is stdout_like
);

# Replacements of Test::Output made by using Test2::Plugin::IOEvents

Expand Down Expand Up @@ -44,5 +48,22 @@ sub stdout_like (&$;$) {
like(stdout_from(sub { $cb->() }), $re, $desc);
}

sub read_file {
my ($file) = @_;
open my $fh, '<', $file
or die "Cannot open $file for read: $!";
local $/ = undef;
my $content = <$fh>;
return $content;
}

sub write_file {
my ($file, $content) = @_;
open my $fh, '>', $file
or die "Cannot open $file for write: $!";
print $fh $content;
close $fh;
return;
}

1;
7 changes: 4 additions & 3 deletions t/command-make-shim.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use lib $FindBin::Bin;

use App::perlbrew;
require "test2_helpers.pl";
use PerlbrewTestHelpers qw(read_file write_file);

mock_perlbrew_install("perl-5.36.1");

Expand Down Expand Up @@ -51,7 +52,7 @@ describe "App::perlbrew->make_shim('foo')" => sub {
mock_perlbrew_use("perl-5.36.1");
my $dir = tempdir();
chdir($dir);
io("foo")->print("hello");
write_file ("foo", "hello");

ok dies {
my $app = App::perlbrew->new("make-shim", "foo");
Expand All @@ -73,7 +74,7 @@ describe "App::perlbrew->make_shim('foo')" => sub {
$app->run();

ok -f "foo", "foo is produced under current directory.";
my $shim_content = io("foo")->slurp;
my $shim_content = read_file("foo");
diag "\nThe content of shim:\n----\n$shim_content\n----\n";
};

Expand All @@ -86,7 +87,7 @@ describe "App::perlbrew->make_shim('foo')" => sub {
$app->run();

ok -f "foo", "foo is produced under current directory.";
my $shim_content = io("foo")->slurp;
my $shim_content = read_file("foo");
diag "\nThe content of shim:\n----\n$shim_content\n----\n";
};
};
Expand Down
8 changes: 6 additions & 2 deletions t/error-http_download-param-validation.t
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/usr/bin/env perl
use Test2::V0;
use File::Temp qw(tempdir);
use IO::All;

use FindBin;
use lib $FindBin::Bin;
use PerlbrewTestHelpers qw(write_file);

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

subtest "http_download: dies when when the download target already exists" => sub {
my $dir = tempdir( CLEANUP => 1 );
my $output = "$dir/whatever";

io($output)->print("so");
write_file($output, "so");

my $error;
like(
Expand Down
13 changes: 9 additions & 4 deletions t/http.t
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/usr/bin/env perl
use Test2::V0;
use Test2::Tools::Spec;
use App::perlbrew;
use File::Temp 'tempdir';
use IO::All;

use App::perlbrew;
use App::Perlbrew::HTTP qw(http_user_agent_program http_get http_download);

use FindBin;
use lib $FindBin::Bin;
use PerlbrewTestHelpers qw( read_file );

unless ($ENV{PERLBREW_DEV_TEST}) {
skip_all => <<REASON;
skip_all <<REASON;
This test invokes HTTP request to external servers and should not be ran in
blind. Whoever which to test this need to set PERLBREW_DEV_TEST env var to 1.
Expand Down Expand Up @@ -65,7 +68,9 @@ REASON
};

it "seems to be downloading the right content" => sub {
is(scalar(io($output)->getline), "#!/bin/sh\n");
my $content = read_file($output);
my ($first_line, undef) = split /\n/, $content, 2;
is ($first_line, "#!/bin/sh");
};
};

Expand Down
5 changes: 3 additions & 2 deletions t/test2_helpers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

use Test2::V0;
use Test2::Plugin::IOEvents;
use IO::All;
use File::Temp qw( tempdir );

use App::Perlbrew::Path;
use App::Perlbrew::Path::Root;

use PerlbrewTestHelpers qw(write_file);

no warnings 'redefine';
sub dir {
App::Perlbrew::Path->new(@_);
Expand Down Expand Up @@ -62,7 +63,7 @@ sub App::perlbrew::do_install_release {
$root->perls($name, "bin")->mkpath;

my $perl = $root->perls ($name, "bin")->child ("perl");
io($perl)->print(<<'CODE');
write_file($perl, <<'CODE');
#!/usr/bin/env perl
use File::Basename;
my $name = basename(dirname(dirname($0))), "\n";
Expand Down

0 comments on commit 8a94cef

Please sign in to comment.