diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-04-03 14:57:29 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-04-03 14:57:29 +0000 |
commit | dfaae12e4d85f7c6821ae4a9fbf7e463d570e7ba (patch) | |
tree | 6dcde6413d8dcd3d24b0251080c21c49fa5b81a6 /t | |
download | Dist-CheckConflicts-tarball-dfaae12e4d85f7c6821ae4a9fbf7e463d570e7ba.tar.gz |
Dist-CheckConflicts-0.11HEADDist-CheckConflicts-0.11master
Diffstat (limited to 't')
70 files changed, 1055 insertions, 0 deletions
diff --git a/t/00-compile.t b/t/00-compile.t new file mode 100644 index 0000000..1980180 --- /dev/null +++ b/t/00-compile.t @@ -0,0 +1,50 @@ +use 5.006; +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.039 + +use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); + + + +my @module_files = ( + 'Dist/CheckConflicts.pm' +); + + + +# no fake home requested + +my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; + +use File::Spec; +use IPC::Open3; +use IO::Handle; + +open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; + +my @warnings; +for my $lib (@module_files) +{ + # see L<perlfaq8/How can I capture STDERR from an external command?> + my $stderr = IO::Handle->new; + + my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); + binmode $stderr, ':crlf' if $^O eq 'MSWin32'; + my @_warnings = <$stderr>; + waitpid($pid, 0); + is($?, 0, "$lib loaded ok"); + + if (@_warnings) + { + warn @_warnings; + push @warnings, @_warnings; + } +} + + + +is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; + + diff --git a/t/also.t b/t/also.t new file mode 100644 index 0000000..b671114 --- /dev/null +++ b/t/also.t @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; +use lib 't/lib/also'; + +{ + require Bar::Conflicts; + is_deeply( + { Bar::Conflicts->conflicts }, + { + 'Bar::Local' => '0.02', + 'Foo::Thing' => '0.01', + 'Foo::Thing::Sub' => '0.05', + }, + "can detect the proper conflicts module" + ); +} + +{ + require Bar::Conflicts2; + is_deeply( + { Bar::Conflicts2->conflicts }, + { + 'Bar::Also' => '0.06', + }, + "unknown also entries are ignored" + ); +} + +done_testing; diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..94b8dbd --- /dev/null +++ b/t/basic.t @@ -0,0 +1,47 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use lib 't/lib/basic'; + +{ + require Foo::Conflicts; + is_deeply( + { Foo::Conflicts->conflicts }, + { + 'Foo::Thing' => '0.01', + 'Foo::Thing::Sub' => '0.05', + }, + "basic conflicts work" + ); +} + +{ + require Bar::Conflicts; + is_deeply( + { Bar::Conflicts->conflicts }, + { + 'Bar::Local' => '0.02', + 'Bar::Also' => '0.06', + 'Bar::Also::Also' => '0.12', + }, + "nested conflicts work" + ); + is_deeply( + { Bar::Conflicts2->conflicts }, + { + 'Bar::Also' => '0.06', + 'Bar::Also::Also' => '0.12', + }, + "nested conflicts work" + ); + is_deeply( + { Bar::Conflicts3->conflicts }, + { + 'Bar::Also::Also' => '0.12', + }, + "nested conflicts work" + ); +} + +done_testing; diff --git a/t/conflicts.t b/t/conflicts.t new file mode 100644 index 0000000..f6f830c --- /dev/null +++ b/t/conflicts.t @@ -0,0 +1,112 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Test::More; +use Test::Fatal; +use lib 't/lib/conflicts'; + +{ + require Foo::Conflicts::Good; + is_deeply( + [ Foo::Conflicts::Good->calculate_conflicts ], + [], + "correct versions for all conflicts", + ); + is( + exception { Foo::Conflicts::Good->check_conflicts }, + undef, + "no conflict error" + ); +} + +{ + require Foo::Conflicts::Bad; + + is_deeply( + [ Foo::Conflicts::Bad->calculate_conflicts ], + [ + { package => 'Foo', installed => '0.02', required => '0.03' }, + { package => 'Foo::Two', installed => '0.02', required => '0.02' }, + ], + "correct versions for all conflicts", + ); + is( + exception { Foo::Conflicts::Bad->check_conflicts }, + "Conflicts detected for Foo::Conflicts::Bad:\n Foo is version 0.02, but must be greater than version 0.03\n Foo::Two is version 0.02, but must be greater than version 0.02\n", + "correct conflict error" + ); +} + +{ + require Bar::Conflicts::Good; + is_deeply( + [ Bar::Conflicts::Good->calculate_conflicts ], + [], + "correct versions for all conflicts", + ); + is( + exception { Bar::Conflicts::Good->check_conflicts }, + undef, + "no conflict error" + ); +} + +{ + require Bar::Conflicts::Bad; + + is_deeply( + [ Bar::Conflicts::Bad->calculate_conflicts ], + [ + { package => 'Bar', installed => '0.02', required => '0.03' }, + { package => 'Bar::Two', installed => '0.02', required => '0.02' }, + ], + "correct versions for all conflicts", + ); + is( + exception { Bar::Conflicts::Bad->check_conflicts }, + "Conflicts detected for Bar::Conflicts::Bad:\n Bar is version 0.02, but must be greater than version 0.03\n Bar::Two is version 0.02, but must be greater than version 0.02\n", + "correct conflict error" + ); +} + +{ + # conflicting module is utterly broken + + require Foo::Conflicts::Broken; + + my @conflicts; + my $warning = ''; + { + local $SIG{__WARN__} = sub { $warning .= $_[0] }; + @conflicts = Foo::Conflicts::Broken->calculate_conflicts; + } + + like $warning, + qr/Warning: Broken did not compile/, + 'Warning is issued when Broken fails to compile'; + + is_deeply( + \@conflicts, + [ + { package => 'Broken', installed => 'unknown', required => '0.03' }, + ], + "correct versions for all conflicts", + ); + + $warning = ''; + { + local $SIG{__WARN__} = sub { $warning .= $_[0] }; + like( + exception { Foo::Conflicts::Broken->check_conflicts }, + qr/^Conflicts detected for Foo::Conflicts::Broken:\n Broken is version unknown, but must be greater than version 0.03\n/, + "correct conflict error", + ); + } + like $warning, + qr/Warning: Broken did not compile/, + 'Warning is also issued when Broken fails to compile', + ; +} + +done_testing; diff --git a/t/dist.t b/t/dist.t new file mode 100644 index 0000000..493de44 --- /dev/null +++ b/t/dist.t @@ -0,0 +1,76 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; +use lib 't/lib/dist'; + +{ + require Foo::Conflicts::Good; + is_deeply( + [ Foo::Conflicts::Good->calculate_conflicts ], + [], + "correct versions for all conflicts", + ); + is( + exception { Foo::Conflicts::Good->check_conflicts }, + undef, + "no conflict error" + ); + is(Foo::Conflicts::Good->dist, 'Foo', "correct dist"); +} + +{ + require Foo::Conflicts::Bad; + + is_deeply( + [ Foo::Conflicts::Bad->calculate_conflicts ], + [ + { package => 'Foo', installed => '0.02', required => '0.03' }, + { package => 'Foo::Two', installed => '0.02', required => '0.02' }, + ], + "correct versions for all conflicts", + ); + is( + exception { Foo::Conflicts::Bad->check_conflicts }, + "Conflicts detected for Foo:\n Foo is version 0.02, but must be greater than version 0.03\n Foo::Two is version 0.02, but must be greater than version 0.02\n", + "correct conflict error" + ); + is(Foo::Conflicts::Bad->dist, 'Foo', "correct dist"); +} + +{ + require Bar::Conflicts::Good; + is_deeply( + [ Bar::Conflicts::Good->calculate_conflicts ], + [], + "correct versions for all conflicts", + ); + is( + exception { Bar::Conflicts::Good->check_conflicts }, + undef, + "no conflict error" + ); + is(Bar::Conflicts::Good->dist, 'Bar', "correct dist"); +} + +{ + require Bar::Conflicts::Bad; + + is_deeply( + [ Bar::Conflicts::Bad->calculate_conflicts ], + [ + { package => 'Bar', installed => '0.02', required => '0.03' }, + { package => 'Bar::Two', installed => '0.02', required => '0.02' }, + ], + "correct versions for all conflicts", + ); + is( + exception { Bar::Conflicts::Bad->check_conflicts }, + "Conflicts detected for Bar:\n Bar is version 0.02, but must be greater than version 0.03\n Bar::Two is version 0.02, but must be greater than version 0.02\n", + "correct conflict error" + ); + is(Bar::Conflicts::Bad->dist, 'Bar', "correct dist"); +} + +done_testing; diff --git a/t/lib/also/Bar/Conflicts.pm b/t/lib/also/Bar/Conflicts.pm new file mode 100644 index 0000000..ffeb56a --- /dev/null +++ b/t/lib/also/Bar/Conflicts.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Local' => 0.02, + }, + -also => [ + 'Foo', + ]; + +1; diff --git a/t/lib/also/Bar/Conflicts2.pm b/t/lib/also/Bar/Conflicts2.pm new file mode 100644 index 0000000..d45754e --- /dev/null +++ b/t/lib/also/Bar/Conflicts2.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts2; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Also' => 0.06, + }, + -also => [ + 'Baz', + ]; + +1; diff --git a/t/lib/also/Foo.pm b/t/lib/also/Foo.pm new file mode 100644 index 0000000..8c4dc16 --- /dev/null +++ b/t/lib/also/Foo.pm @@ -0,0 +1,5 @@ +package Foo; + +sub foo { } + +1; diff --git a/t/lib/also/Foo/Conflicts.pm b/t/lib/also/Foo/Conflicts.pm new file mode 100644 index 0000000..0d9d7ef --- /dev/null +++ b/t/lib/also/Foo/Conflicts.pm @@ -0,0 +1,11 @@ +package Foo::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo::Thing' => 0.01, + 'Foo::Thing::Sub' => 0.05, + }; + +1; diff --git a/t/lib/basic/Bar/Conflicts.pm b/t/lib/basic/Bar/Conflicts.pm new file mode 100644 index 0000000..65ba026 --- /dev/null +++ b/t/lib/basic/Bar/Conflicts.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Local' => 0.02, + }, + -also => [ + 'Bar::Conflicts2', + ]; + +1; diff --git a/t/lib/basic/Bar/Conflicts2.pm b/t/lib/basic/Bar/Conflicts2.pm new file mode 100644 index 0000000..a26606c --- /dev/null +++ b/t/lib/basic/Bar/Conflicts2.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts2; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Also' => 0.06, + }, + -also => [ + 'Bar::Conflicts3', + ]; + +1; diff --git a/t/lib/basic/Bar/Conflicts3.pm b/t/lib/basic/Bar/Conflicts3.pm new file mode 100644 index 0000000..4c30909 --- /dev/null +++ b/t/lib/basic/Bar/Conflicts3.pm @@ -0,0 +1,10 @@ +package Bar::Conflicts3; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Also::Also' => 0.12, + }; + +1; diff --git a/t/lib/basic/Foo/Conflicts.pm b/t/lib/basic/Foo/Conflicts.pm new file mode 100644 index 0000000..0d9d7ef --- /dev/null +++ b/t/lib/basic/Foo/Conflicts.pm @@ -0,0 +1,11 @@ +package Foo::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo::Thing' => 0.01, + 'Foo::Thing::Sub' => 0.05, + }; + +1; diff --git a/t/lib/conflicts/Bar.pm b/t/lib/conflicts/Bar.pm new file mode 100644 index 0000000..0ce51ad --- /dev/null +++ b/t/lib/conflicts/Bar.pm @@ -0,0 +1,7 @@ +package Bar; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/conflicts/Bar/Conflicts/Bad.pm b/t/lib/conflicts/Bar/Conflicts/Bad.pm new file mode 100644 index 0000000..32a654e --- /dev/null +++ b/t/lib/conflicts/Bar/Conflicts/Bad.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts::Bad; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar' => '0.03', + }, + -also => [ + 'Bar::Conflicts::Bad2', + ]; + +1; diff --git a/t/lib/conflicts/Bar/Conflicts/Bad2.pm b/t/lib/conflicts/Bar/Conflicts/Bad2.pm new file mode 100644 index 0000000..9c76862 --- /dev/null +++ b/t/lib/conflicts/Bar/Conflicts/Bad2.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts::Bad2; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Two' => '0.02', + }, + -also => [ + 'Bar::Conflicts::Bad3', + ]; + +1; diff --git a/t/lib/conflicts/Bar/Conflicts/Bad3.pm b/t/lib/conflicts/Bar/Conflicts/Bad3.pm new file mode 100644 index 0000000..fb80b9e --- /dev/null +++ b/t/lib/conflicts/Bar/Conflicts/Bad3.pm @@ -0,0 +1,10 @@ +package Bar::Conflicts::Bad3; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Three' => '0.01', + }; + +1; diff --git a/t/lib/conflicts/Bar/Conflicts/Good.pm b/t/lib/conflicts/Bar/Conflicts/Good.pm new file mode 100644 index 0000000..0f74447 --- /dev/null +++ b/t/lib/conflicts/Bar/Conflicts/Good.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts::Good; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar' => '0.01', + }, + -also => [ + 'Bar::Conflicts::Good2', + ]; + +1; diff --git a/t/lib/conflicts/Bar/Conflicts/Good2.pm b/t/lib/conflicts/Bar/Conflicts/Good2.pm new file mode 100644 index 0000000..8ba9fd3 --- /dev/null +++ b/t/lib/conflicts/Bar/Conflicts/Good2.pm @@ -0,0 +1,13 @@ +package Bar::Conflicts::Good2; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Two' => '0.01', + }, + -also => [ + 'Bar::Conflicts::Good3', + ]; + +1; diff --git a/t/lib/conflicts/Bar/Conflicts/Good3.pm b/t/lib/conflicts/Bar/Conflicts/Good3.pm new file mode 100644 index 0000000..88b542e --- /dev/null +++ b/t/lib/conflicts/Bar/Conflicts/Good3.pm @@ -0,0 +1,10 @@ +package Bar::Conflicts::Good3; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Bar::Three' => '0.01', + }; + +1; diff --git a/t/lib/conflicts/Bar/Three.pm b/t/lib/conflicts/Bar/Three.pm new file mode 100644 index 0000000..8c304fe --- /dev/null +++ b/t/lib/conflicts/Bar/Three.pm @@ -0,0 +1,7 @@ +package Bar::Three; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/conflicts/Bar/Two.pm b/t/lib/conflicts/Bar/Two.pm new file mode 100644 index 0000000..172ad51 --- /dev/null +++ b/t/lib/conflicts/Bar/Two.pm @@ -0,0 +1,7 @@ +package Bar::Two; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/conflicts/Broken.pm b/t/lib/conflicts/Broken.pm new file mode 100644 index 0000000..de400c3 --- /dev/null +++ b/t/lib/conflicts/Broken.pm @@ -0,0 +1,3 @@ +package Broken; + +die 'this module is utterly broken'; diff --git a/t/lib/conflicts/Foo.pm b/t/lib/conflicts/Foo.pm new file mode 100644 index 0000000..9660e6d --- /dev/null +++ b/t/lib/conflicts/Foo.pm @@ -0,0 +1,7 @@ +package Foo; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/conflicts/Foo/Conflicts/Bad.pm b/t/lib/conflicts/Foo/Conflicts/Bad.pm new file mode 100644 index 0000000..1cbf30f --- /dev/null +++ b/t/lib/conflicts/Foo/Conflicts/Bad.pm @@ -0,0 +1,12 @@ +package Foo::Conflicts::Bad; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo' => 0.03, + 'Foo::Two' => 0.02, + 'Foo::Three' => 0.01, + }; + +1; diff --git a/t/lib/conflicts/Foo/Conflicts/Broken.pm b/t/lib/conflicts/Foo/Conflicts/Broken.pm new file mode 100644 index 0000000..87043ae --- /dev/null +++ b/t/lib/conflicts/Foo/Conflicts/Broken.pm @@ -0,0 +1,11 @@ +package Foo::Conflicts::Broken; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Broken' => '0.03', + 'NotInstalled' => '0.01', + }; + +1; diff --git a/t/lib/conflicts/Foo/Conflicts/Good.pm b/t/lib/conflicts/Foo/Conflicts/Good.pm new file mode 100644 index 0000000..33d15de --- /dev/null +++ b/t/lib/conflicts/Foo/Conflicts/Good.pm @@ -0,0 +1,13 @@ +package Foo::Conflicts::Good; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo' => 0.01, + 'Foo::Two' => 0.01, + 'Foo::Three' => 0.01, + 'NotInstalled' => '0.01', + }; + +1; diff --git a/t/lib/conflicts/Foo/Three.pm b/t/lib/conflicts/Foo/Three.pm new file mode 100644 index 0000000..b180934 --- /dev/null +++ b/t/lib/conflicts/Foo/Three.pm @@ -0,0 +1,7 @@ +package Foo::Three; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/conflicts/Foo/Two.pm b/t/lib/conflicts/Foo/Two.pm new file mode 100644 index 0000000..7a1daff --- /dev/null +++ b/t/lib/conflicts/Foo/Two.pm @@ -0,0 +1,7 @@ +package Foo::Two; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/dist/Bar.pm b/t/lib/dist/Bar.pm new file mode 100644 index 0000000..0ce51ad --- /dev/null +++ b/t/lib/dist/Bar.pm @@ -0,0 +1,7 @@ +package Bar; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/dist/Bar/Conflicts/Bad.pm b/t/lib/dist/Bar/Conflicts/Bad.pm new file mode 100644 index 0000000..af25aab --- /dev/null +++ b/t/lib/dist/Bar/Conflicts/Bad.pm @@ -0,0 +1,14 @@ +package Bar::Conflicts::Bad; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Bar', + -conflicts => { + 'Bar' => '0.03', + }, + -also => [ + 'Bar::Conflicts::Bad2', + ]; + +1; diff --git a/t/lib/dist/Bar/Conflicts/Bad2.pm b/t/lib/dist/Bar/Conflicts/Bad2.pm new file mode 100644 index 0000000..c4f1c1a --- /dev/null +++ b/t/lib/dist/Bar/Conflicts/Bad2.pm @@ -0,0 +1,14 @@ +package Bar::Conflicts::Bad2; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Bar', + -conflicts => { + 'Bar::Two' => '0.02', + }, + -also => [ + 'Bar::Conflicts::Bad3', + ]; + +1; diff --git a/t/lib/dist/Bar/Conflicts/Bad3.pm b/t/lib/dist/Bar/Conflicts/Bad3.pm new file mode 100644 index 0000000..be23e3c --- /dev/null +++ b/t/lib/dist/Bar/Conflicts/Bad3.pm @@ -0,0 +1,11 @@ +package Bar::Conflicts::Bad3; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Bar', + -conflicts => { + 'Bar::Three' => '0.01', + }; + +1; diff --git a/t/lib/dist/Bar/Conflicts/Good.pm b/t/lib/dist/Bar/Conflicts/Good.pm new file mode 100644 index 0000000..cd64e57 --- /dev/null +++ b/t/lib/dist/Bar/Conflicts/Good.pm @@ -0,0 +1,14 @@ +package Bar::Conflicts::Good; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Bar', + -conflicts => { + 'Bar' => '0.01', + }, + -also => [ + 'Bar::Conflicts::Good2', + ]; + +1; diff --git a/t/lib/dist/Bar/Conflicts/Good2.pm b/t/lib/dist/Bar/Conflicts/Good2.pm new file mode 100644 index 0000000..ed98ddc --- /dev/null +++ b/t/lib/dist/Bar/Conflicts/Good2.pm @@ -0,0 +1,14 @@ +package Bar::Conflicts::Good2; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Bar', + -conflicts => { + 'Bar::Two' => '0.01', + }, + -also => [ + 'Bar::Conflicts::Good3', + ]; + +1; diff --git a/t/lib/dist/Bar/Conflicts/Good3.pm b/t/lib/dist/Bar/Conflicts/Good3.pm new file mode 100644 index 0000000..7bb0943 --- /dev/null +++ b/t/lib/dist/Bar/Conflicts/Good3.pm @@ -0,0 +1,11 @@ +package Bar::Conflicts::Good3; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Bar', + -conflicts => { + 'Bar::Three' => '0.01', + }; + +1; diff --git a/t/lib/dist/Bar/Three.pm b/t/lib/dist/Bar/Three.pm new file mode 100644 index 0000000..8c304fe --- /dev/null +++ b/t/lib/dist/Bar/Three.pm @@ -0,0 +1,7 @@ +package Bar::Three; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/dist/Bar/Two.pm b/t/lib/dist/Bar/Two.pm new file mode 100644 index 0000000..172ad51 --- /dev/null +++ b/t/lib/dist/Bar/Two.pm @@ -0,0 +1,7 @@ +package Bar::Two; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/dist/Foo.pm b/t/lib/dist/Foo.pm new file mode 100644 index 0000000..9660e6d --- /dev/null +++ b/t/lib/dist/Foo.pm @@ -0,0 +1,7 @@ +package Foo; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/dist/Foo/Conflicts/Bad.pm b/t/lib/dist/Foo/Conflicts/Bad.pm new file mode 100644 index 0000000..22905ee --- /dev/null +++ b/t/lib/dist/Foo/Conflicts/Bad.pm @@ -0,0 +1,13 @@ +package Foo::Conflicts::Bad; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Foo', + -conflicts => { + 'Foo' => 0.03, + 'Foo::Two' => 0.02, + 'Foo::Three' => 0.01, + }; + +1; diff --git a/t/lib/dist/Foo/Conflicts/Good.pm b/t/lib/dist/Foo/Conflicts/Good.pm new file mode 100644 index 0000000..553c698 --- /dev/null +++ b/t/lib/dist/Foo/Conflicts/Good.pm @@ -0,0 +1,13 @@ +package Foo::Conflicts::Good; +use strict; +use warnings; + +use Dist::CheckConflicts + -dist => 'Foo', + -conflicts => { + 'Foo' => 0.01, + 'Foo::Two' => 0.01, + 'Foo::Three' => 0.01, + }; + +1; diff --git a/t/lib/dist/Foo/Three.pm b/t/lib/dist/Foo/Three.pm new file mode 100644 index 0000000..b180934 --- /dev/null +++ b/t/lib/dist/Foo/Three.pm @@ -0,0 +1,7 @@ +package Foo::Three; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/dist/Foo/Two.pm b/t/lib/dist/Foo/Two.pm new file mode 100644 index 0000000..7a1daff --- /dev/null +++ b/t/lib/dist/Foo/Two.pm @@ -0,0 +1,7 @@ +package Foo::Two; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/merge/Foo/Conflicts.pm b/t/lib/merge/Foo/Conflicts.pm new file mode 100644 index 0000000..3691702 --- /dev/null +++ b/t/lib/merge/Foo/Conflicts.pm @@ -0,0 +1,15 @@ +package Foo::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo::One' => 0.01, + 'Foo::Two' => 0.03, + 'Foo::Three' => 0.02, + }, + -also => [ + 'Foo::Conflicts2', + ]; + +1; diff --git a/t/lib/merge/Foo/Conflicts2.pm b/t/lib/merge/Foo/Conflicts2.pm new file mode 100644 index 0000000..b782a2b --- /dev/null +++ b/t/lib/merge/Foo/Conflicts2.pm @@ -0,0 +1,12 @@ +package Foo::Conflicts2; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo::One' => 0.03, + 'Foo::Two' => 0.01, + 'Foo::Four' => 0.02, + }; + +1; diff --git a/t/lib/runtime/Bar.pm b/t/lib/runtime/Bar.pm new file mode 100644 index 0000000..8691a44 --- /dev/null +++ b/t/lib/runtime/Bar.pm @@ -0,0 +1,13 @@ +package Bar; +use strict; +use warnings; + +use Bar::Foo; +use Bar::Baz; + +use Bar::Conflicts; + +use Bar::Bar; +use Bar::Quux; + +1; diff --git a/t/lib/runtime/Bar/Bar.pm b/t/lib/runtime/Bar/Bar.pm new file mode 100644 index 0000000..d532db6 --- /dev/null +++ b/t/lib/runtime/Bar/Bar.pm @@ -0,0 +1,18 @@ +package Bar::Bar; +use strict; +use warnings; + +use Bar::Bar::Good; +use Bar::Bar::Bad; + +our $VERSION = 0.01; + +sub contents { + local $/; + <DATA> +} + +1; + +__DATA__ +__DATA__ for Bar::Bar diff --git a/t/lib/runtime/Bar/Bar/Bad.pm b/t/lib/runtime/Bar/Bar/Bad.pm new file mode 100644 index 0000000..9a4792b --- /dev/null +++ b/t/lib/runtime/Bar/Bar/Bad.pm @@ -0,0 +1,7 @@ +package Bar::Bar::Bad; +use strict; +use warnings; + +our $VERSION = 0.01; + +1; diff --git a/t/lib/runtime/Bar/Bar/Good.pm b/t/lib/runtime/Bar/Bar/Good.pm new file mode 100644 index 0000000..58e6d78 --- /dev/null +++ b/t/lib/runtime/Bar/Bar/Good.pm @@ -0,0 +1,7 @@ +package Bar::Bar::Good; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/runtime/Bar/Baz.pm b/t/lib/runtime/Bar/Baz.pm new file mode 100644 index 0000000..b4db03b --- /dev/null +++ b/t/lib/runtime/Bar/Baz.pm @@ -0,0 +1,18 @@ +package Bar::Baz; +use strict; +use warnings; + +use Bar::Baz::Good; +use Bar::Baz::Bad; + +our $VERSION = 0.02; + +sub contents { + local $/; + <DATA> +} + +1; + +__DATA__ +__DATA__ for Bar::Baz diff --git a/t/lib/runtime/Bar/Baz/Bad.pm b/t/lib/runtime/Bar/Baz/Bad.pm new file mode 100644 index 0000000..c92da0e --- /dev/null +++ b/t/lib/runtime/Bar/Baz/Bad.pm @@ -0,0 +1,7 @@ +package Bar::Baz::Bad; +use strict; +use warnings; + +our $VERSION = 0.01; + +1; diff --git a/t/lib/runtime/Bar/Baz/Good.pm b/t/lib/runtime/Bar/Baz/Good.pm new file mode 100644 index 0000000..2205717 --- /dev/null +++ b/t/lib/runtime/Bar/Baz/Good.pm @@ -0,0 +1,7 @@ +package Bar::Baz::Good; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/runtime/Bar/Conflicts.pm b/t/lib/runtime/Bar/Conflicts.pm new file mode 100644 index 0000000..c9c6f3d --- /dev/null +++ b/t/lib/runtime/Bar/Conflicts.pm @@ -0,0 +1,22 @@ +package Bar::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + ':runtime', + -conflicts => { + 'Bar::Foo' => 0.01, + 'Bar::Foo::Good' => 0.01, + 'Bar::Foo::Bad' => 0.01, + 'Bar::Bar' => 0.01, + 'Bar::Bar::Good' => 0.01, + 'Bar::Bar::Bad' => 0.01, + 'Bar::Baz' => 0.01, + 'Bar::Baz::Good' => 0.01, + 'Bar::Baz::Bad' => 0.01, + 'Bar::Quux' => 0.01, + 'Bar::Quux::Good' => 0.01, + 'Bar::Quux::Bad' => 0.01, + }; + +1; diff --git a/t/lib/runtime/Bar/Foo.pm b/t/lib/runtime/Bar/Foo.pm new file mode 100644 index 0000000..99341ac --- /dev/null +++ b/t/lib/runtime/Bar/Foo.pm @@ -0,0 +1,18 @@ +package Bar::Foo; +use strict; +use warnings; + +use Bar::Foo::Good; +use Bar::Foo::Bad; + +our $VERSION = 0.01; + +sub contents { + local $/; + <DATA> +} + +1; + +__DATA__ +__DATA__ for Bar::Foo diff --git a/t/lib/runtime/Bar/Foo/Bad.pm b/t/lib/runtime/Bar/Foo/Bad.pm new file mode 100644 index 0000000..d4a58d3 --- /dev/null +++ b/t/lib/runtime/Bar/Foo/Bad.pm @@ -0,0 +1,7 @@ +package Bar::Foo::Bad; +use strict; +use warnings; + +our $VERSION = 0.01; + +1; diff --git a/t/lib/runtime/Bar/Foo/Good.pm b/t/lib/runtime/Bar/Foo/Good.pm new file mode 100644 index 0000000..f5d8b73 --- /dev/null +++ b/t/lib/runtime/Bar/Foo/Good.pm @@ -0,0 +1,7 @@ +package Bar::Foo::Good; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/runtime/Bar/Quux.pm b/t/lib/runtime/Bar/Quux.pm new file mode 100644 index 0000000..1ec6f35 --- /dev/null +++ b/t/lib/runtime/Bar/Quux.pm @@ -0,0 +1,18 @@ +package Bar::Quux; +use strict; +use warnings; + +use Bar::Quux::Good; +use Bar::Quux::Bad; + +our $VERSION = 0.02; + +sub contents { + local $/; + <DATA> +} + +1; + +__DATA__ +__DATA__ for Bar::Quux diff --git a/t/lib/runtime/Bar/Quux/Bad.pm b/t/lib/runtime/Bar/Quux/Bad.pm new file mode 100644 index 0000000..2238323 --- /dev/null +++ b/t/lib/runtime/Bar/Quux/Bad.pm @@ -0,0 +1,7 @@ +package Bar::Quux::Bad; +use strict; +use warnings; + +our $VERSION = 0.01; + +1; diff --git a/t/lib/runtime/Bar/Quux/Good.pm b/t/lib/runtime/Bar/Quux/Good.pm new file mode 100644 index 0000000..8692c2c --- /dev/null +++ b/t/lib/runtime/Bar/Quux/Good.pm @@ -0,0 +1,7 @@ +package Bar::Quux::Good; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/runtime/Foo.pm b/t/lib/runtime/Foo.pm new file mode 100644 index 0000000..5fd77ef --- /dev/null +++ b/t/lib/runtime/Foo.pm @@ -0,0 +1,13 @@ +package Foo; +use strict; +use warnings; + +use Foo::Foo; +use Foo::Baz; + +use Foo::Conflicts; + +use Foo::Bar; +use Foo::Quux; + +1; diff --git a/t/lib/runtime/Foo/Bar.pm b/t/lib/runtime/Foo/Bar.pm new file mode 100644 index 0000000..c4c6af8 --- /dev/null +++ b/t/lib/runtime/Foo/Bar.pm @@ -0,0 +1,7 @@ +package Foo::Bar; +use strict; +use warnings; + +our $VERSION = 0.01; + +1; diff --git a/t/lib/runtime/Foo/Baz.pm b/t/lib/runtime/Foo/Baz.pm new file mode 100644 index 0000000..665f3b5 --- /dev/null +++ b/t/lib/runtime/Foo/Baz.pm @@ -0,0 +1,7 @@ +package Foo::Baz; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/runtime/Foo/Conflicts.pm b/t/lib/runtime/Foo/Conflicts.pm new file mode 100644 index 0000000..34ea4b0 --- /dev/null +++ b/t/lib/runtime/Foo/Conflicts.pm @@ -0,0 +1,14 @@ +package Foo::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + ':runtime', + -conflicts => { + 'Foo::Foo' => 0.01, + 'Foo::Bar' => 0.01, + 'Foo::Baz' => 0.01, + 'Foo::Quux' => 0.01, + }; + +1; diff --git a/t/lib/runtime/Foo/Foo.pm b/t/lib/runtime/Foo/Foo.pm new file mode 100644 index 0000000..ca6c28e --- /dev/null +++ b/t/lib/runtime/Foo/Foo.pm @@ -0,0 +1,7 @@ +package Foo::Foo; +use strict; +use warnings; + +our $VERSION = 0.01; + +1; diff --git a/t/lib/runtime/Foo/Quux.pm b/t/lib/runtime/Foo/Quux.pm new file mode 100644 index 0000000..f813ae3 --- /dev/null +++ b/t/lib/runtime/Foo/Quux.pm @@ -0,0 +1,7 @@ +package Foo::Quux; +use strict; +use warnings; + +our $VERSION = 0.02; + +1; diff --git a/t/lib/warn/Foo/Conflicts.pm b/t/lib/warn/Foo/Conflicts.pm new file mode 100644 index 0000000..e55ead3 --- /dev/null +++ b/t/lib/warn/Foo/Conflicts.pm @@ -0,0 +1,10 @@ +package Foo::Conflicts; +use strict; +use warnings; + +use Dist::CheckConflicts + -conflicts => { + 'Foo::Thing' => 0.01, + }; + +1; diff --git a/t/lib/warn/Foo/Thing.pm b/t/lib/warn/Foo/Thing.pm new file mode 100644 index 0000000..8dfa0b4 --- /dev/null +++ b/t/lib/warn/Foo/Thing.pm @@ -0,0 +1,9 @@ +package Foo::Thing; +use strict; +use warnings; + +our $VERSION = 0.02; + +warn "Loading Foo::Thing"; + +1; diff --git a/t/merge.t b/t/merge.t new file mode 100644 index 0000000..074efaf --- /dev/null +++ b/t/merge.t @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use lib 't/lib/merge'; + +{ + require Foo::Conflicts; + is_deeply( + { Foo::Conflicts->conflicts }, + { + 'Foo::One' => '0.03', + 'Foo::Two' => '0.03', + 'Foo::Three' => '0.02', + 'Foo::Four' => '0.02', + }, + "got the right conflicts" + ); +} + +done_testing; diff --git a/t/runtime.t b/t/runtime.t new file mode 100644 index 0000000..5125e91 --- /dev/null +++ b/t/runtime.t @@ -0,0 +1,49 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use lib 't/lib/runtime'; + +use Module::Runtime 'require_module'; + +sub warnings_ok { + my ($class, @conflicts) = @_; + local $Test::Builder::Level = $Test::Builder::Level + 1; + @conflicts = sort map { "Conflict detected for $_->[0]:\n $_->[1] is version $_->[2], but must be greater than version $_->[3]\n" } @conflicts; + + my @warnings; + { + local $SIG{__WARN__} = sub { push @warnings, $_[0] }; + require_module($class); + } + @warnings = sort @warnings; + + is_deeply(\@warnings, \@conflicts, "correct runtime warnings for $class"); +} + +warnings_ok( + 'Foo', + ['Foo::Conflicts', 'Foo::Foo', '0.01', '0.01'], + ['Foo::Conflicts', 'Foo::Bar', '0.01', '0.01'], +); +warnings_ok( + 'Bar', + ['Bar::Conflicts', 'Bar::Baz::Bad', '0.01', '0.01'], + ['Bar::Conflicts', 'Bar::Foo::Bad', '0.01', '0.01'], + ['Bar::Conflicts', 'Bar::Foo', '0.01', '0.01'], + ['Bar::Conflicts', 'Bar::Bar::Bad', '0.01', '0.01'], + ['Bar::Conflicts', 'Bar::Bar', '0.01', '0.01'], + ['Bar::Conflicts', 'Bar::Quux::Bad', '0.01', '0.01'], +); + +is(Bar::Foo->contents, "__DATA__ for Bar::Foo\n", "__DATA__ sections intact"); +is(Bar::Bar->contents, "__DATA__ for Bar::Bar\n", "__DATA__ sections intact"); +is(Bar::Baz->contents, "__DATA__ for Bar::Baz\n", "__DATA__ sections intact"); +is(Bar::Quux->contents, "__DATA__ for Bar::Quux\n", "__DATA__ sections intact"); + +is(scalar(grep { ref($_) eq 'ARRAY' && @$_ > 1 && ref($_->[1]) eq 'HASH' } + @INC), + 1, + "only installed one \@INC hook"); + +done_testing; diff --git a/t/warn.t b/t/warn.t new file mode 100644 index 0000000..3f3ce33 --- /dev/null +++ b/t/warn.t @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use lib 't/lib/warn'; + +{ + require Foo::Conflicts; + + my $warning = ''; + local $SIG{__WARN__} = sub { $warning .= $_[0] }; + my $conflicts = Foo::Conflicts->calculate_conflicts; + is($warning, '', "we don't see warnings from loaded modules"); +} + +done_testing; |