Skip to content

Commit

Permalink
Merge pull request #807 from lukec/Test2-start
Browse files Browse the repository at this point in the history
Start migrating to Test2
  • Loading branch information
gugod authored Jun 15, 2024
2 parents dc55b5d + 124a7f2 commit a67a8ba
Show file tree
Hide file tree
Showing 50 changed files with 435 additions and 357 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ NEXT
- bashrc executes properly in bash shells with +h option set
- Allow specification of non-standard Perl location
- make-pp now requires the input to be specified with `-i` or `--input`.
- Start to port tests to Test2

0.98
- Released at 2023-08-11T22:54:38+0900
Expand Down
5 changes: 4 additions & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
"Test::Output" : "1.03",
"Test::Simple" : "1.001002",
"Test::Spec" : "0.49",
"Test::TempDir::Tiny" : "0.016"
"Test::TempDir::Tiny" : "0.016",
"Test2::V0" : "0.000163",
"Test2::Plugin::NoWarnings" : "0.10",
"Test2::Plugin::IOEvents" : "0.001001"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ build_requires:
Test::Simple: '1.001002'
Test::Spec: '0.49'
Test::TempDir::Tiny: '0.016'
Test2::V0 : '0.000163'
Test2::Plugin::NoWarnings : '0.10'
Test2::Plugin::IOEvents : '0.001001'
configure_requires:
Module::Build::Tiny: '0.039'
dynamic_config: 0
Expand Down
3 changes: 3 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ on test => sub {
requires 'Test::Simple' => '1.001002';
requires 'Test::Spec' => '0.49';
requires 'Test::TempDir::Tiny' => '0.016';
requires 'Test2::V0' => '0.000163';
requires 'Test2::Plugin::NoWarnings' => '0.10';
requires 'Test2::Plugin::IOEvents' => '0.001001';
};

on develop => sub {
Expand Down
6 changes: 4 additions & 2 deletions t/00.load.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env perl
use Test2::V0;
use strict;
use Test::More tests => 1;
use lib qw(lib);

use_ok('App::perlbrew');
plan 1;

use ok 'App::perlbrew';


24 changes: 12 additions & 12 deletions t/01.options.t
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#!perl
use strict;
use Test::More tests => 12;
use Test2::V0;
use Data::Dumper;

use App::perlbrew;

my $app = App::perlbrew->new('install', '-n', 'perl-5.12.1',
'-Dusethreads', '-DDEBUGGING', '-Uusemymalloc', '-Accflags');

note explain($app)
if (main->can('note') && main->can('explain'));
note Dumper($app);

is join(' ', $app->args), join(' ', qw(install perl-5.12.1));

is_deeply $app->{D}, [qw(usethreads DEBUGGING)], '-D';
is_deeply $app->{U}, [qw(usemymalloc)], '-U';
is_deeply $app->{A}, [qw(ccflags)], '-A';
is $app->{D}, [qw(usethreads DEBUGGING)], '-D';
is $app->{U}, [qw(usemymalloc)], '-U';
is $app->{A}, [qw(ccflags)], '-A';

ok !$app->{quiet}, 'not quiet';
ok $app->{notest}, 'notest';

$app = App::perlbrew->new('install', '--quiet', 'perl-5.12.1',
'-D', 'usethreads', '-D=DEBUGGING', '-U', 'usemymalloc', '-A', 'ccflags');

note explain($app)
if (main->can('note') && main->can('explain'));
note Dumper($app);

is join(' ', $app->args), join(' ', qw(install perl-5.12.1));

is_deeply $app->{D}, [qw(usethreads DEBUGGING)], '-D';
is_deeply $app->{U}, [qw(usemymalloc)], '-U';
is_deeply $app->{A}, [qw(ccflags)], '-A';
is $app->{D}, [qw(usethreads DEBUGGING)], '-D';
is $app->{U}, [qw(usemymalloc)], '-U';
is $app->{A}, [qw(ccflags)], '-A';

ok $app->{quiet}, 'quiet';
ok !$app->{notest}, 'notest';

done_testing;
8 changes: 3 additions & 5 deletions t/02.format_perl_version.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;
use English qw( -no_match_vars );
use Test::More;

use App::perlbrew;
use Test::NoWarnings;
use Test2::Plugin::NoWarnings;

my @test_cases = (
{
Expand All @@ -26,7 +24,7 @@ my @test_cases = (
},
);

plan tests => scalar @test_cases + 1;
plan scalar @test_cases;
{
my $app = App::perlbrew->new();
TEST:
Expand Down
6 changes: 2 additions & 4 deletions t/03.test_get_available_versions.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test2::V0;
use App::perlbrew;

{
Expand All @@ -20,7 +18,7 @@ use App::perlbrew;
}
}

plan tests => 12;
plan 12;

my $app = App::perlbrew->new();
my $dists = $app->available_perl_distributions();
Expand Down
6 changes: 2 additions & 4 deletions t/04.find_available_perls.t
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test2::V0;
use App::perlbrew;

plan tests => 52;
plan 52;

my $html = <<HERE;
<!-- LATEST_RELEASES -->
Expand Down
25 changes: 13 additions & 12 deletions t/05.get_current_perl.t
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;
use Test2::Plugin::IOEvents;

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';

use Test::More;
use Test::Output;
require 'test2_helpers.pl';

mock_perlbrew_install("perl-5.12.3");
mock_perlbrew_install("perl-5.12.4");
Expand All @@ -18,12 +15,16 @@ mock_perlbrew_install("perl-5.14.2");
subtest "perlbrew version" => sub {

my $version = $App::perlbrew::VERSION;
stdout_like(
sub {
my $app = App::perlbrew->new("version");
$app->run;
} =>
qr{(?:\./)?\Qt/05.get_current_perl.t - App::perlbrew/$version\E\n}
my $events = intercept {
my $app = App::perlbrew->new("version");
$app->run;
};
like(
$events,
[
{info => [{tag => 'STDOUT', details => qr{(?:\./)?\Qt/05.get_current_perl.t - App::perlbrew/$version\E\n}}]}
],
'perlbrew version matches'
);
};

Expand Down
7 changes: 2 additions & 5 deletions t/06.installed_perls.t
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;

use Test::More;
use App::perlbrew;

my $app = App::perlbrew->new();
my @perls = $app->installed_perls;

unless(@perls) {
plan skip_all => "No perl installation under PERLBREW_ROOT";
exit;
skip_all("No perl installation under PERLBREW_ROOT");
}

for my $perl (@perls) {
Expand Down
4 changes: 1 addition & 3 deletions t/07.argv.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test2::V0;
use App::perlbrew;

{
Expand Down
19 changes: 9 additions & 10 deletions t/08.error_available.t
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;

use App::perlbrew;
use Test::More;
use Test::Exception;

no warnings 'redefine';
sub App::perlbrew::http_get { "" }

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("available");
$app->run;
},
qr[ERROR:]
qr[ERROR:],
'got Error from available'
);

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("available");
my $ret = $app->available_perl_distributions();
},
qr[ERROR:]
qr[ERROR:],
'got Error from available_perl_distributions'
);

done_testing;
9 changes: 3 additions & 6 deletions t/08.error_install.t
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;

use Test::More;
use Test::Exception;
use File::Temp qw(tempdir);

use App::perlbrew;
Expand All @@ -19,8 +16,8 @@ App::Perlbrew::Path->new ($ENV{PERLBREW_ROOT})->child ("dists")->mkpath;
no warnings 'redefine';
sub App::perlbrew::http_download { return "ERROR" }

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("install", "perl-5.12.3");
$app->run;
},
Expand Down
22 changes: 10 additions & 12 deletions t/08.error_install_blead.t
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';

use Test::More;
use Test::Exception;
require 'test2_helpers.pl';

use App::perlbrew;
{
no warnings 'redefine';
sub App::perlbrew::http_download { return "ERROR" }
}

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("install", "perl-blead");
$app->run;
},
qr[ERROR: Failed to download https://.+/blead\.tar\.gz]
qr[ERROR: Failed to download https://.+/blead\.tar\.gz],
'install blead-perl failed'
);

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("install", "blead");
$app->run;
},
qr[ERROR: Failed to download https://.+/blead\.tar\.gz]
qr[ERROR: Failed to download https://.+/blead\.tar\.gz],
'install blead failed'
);

done_testing;
12 changes: 4 additions & 8 deletions t/08.error_install_cpanm.t
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';

use Test::More;
use Test::Exception;
require 'test2_helpers.pl';

no warnings 'redefine';
sub App::perlbrew::http_get { "" }

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("install-cpanm");
$app->run;
},
Expand Down
12 changes: 4 additions & 8 deletions t/08.error_install_cpm.t
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';

use Test::More;
use Test::Exception;
require 'test2_helpers.pl';

no warnings 'redefine';
sub App::perlbrew::http_get { "" }

throws_ok(
sub {
like(
dies {
my $app = App::perlbrew->new("install-cpm");
$app->run;
},
Expand Down
Loading

0 comments on commit a67a8ba

Please sign in to comment.