summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-01-13 14:04:14 -0600
committerJesse Luehrs <doy@tozt.net>2011-01-13 14:04:14 -0600
commit2239a2c36e607ad9a91f06b088b1f96b39084c58 (patch)
tree6c610e6bd18e6b6ac8c204e9623f6bddc766e0e3
parent197e3362e92f58cba6ce3d60e1b12ca0ed3c69ce (diff)
downloaddist-checkconflicts-2239a2c36e607ad9a91f06b088b1f96b39084c58.tar.gz
dist-checkconflicts-2239a2c36e607ad9a91f06b088b1f96b39084c58.zip
actually, the first set of warnings is unordered, account for that0.03
-rw-r--r--t/02-conflicts.t50
-rw-r--r--t/03-dist.t50
-rw-r--r--t/06-runtime.t52
3 files changed, 78 insertions, 74 deletions
diff --git a/t/02-conflicts.t b/t/02-conflicts.t
index e788815..663b1e8 100644
--- a/t/02-conflicts.t
+++ b/t/02-conflicts.t
@@ -5,6 +5,21 @@ use Test::More;
use Test::Fatal;
use lib 't/lib/02';
+sub use_ok_warnings {
+ 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] };
+ use_ok($class);
+ }
+ @warnings = sort @warnings;
+
+ is_deeply(\@warnings, \@conflicts, "correct runtime warnings for $class");
+}
+
{
use_ok('Foo::Conflicts::Good');
is_deeply(
@@ -20,17 +35,11 @@ use lib 't/lib/02';
}
{
- {
- my $warnings;
- local $SIG{__WARN__} = sub { $warnings .= $_[0] };
- use_ok('Foo::Conflicts::Bad');
- is($warnings, <<'EOF', "got correct runtime warnings");
-Conflict detected for Foo::Conflicts::Bad:
- Foo::Two is version 0.02, but must be greater than version 0.02
-Conflict detected for Foo::Conflicts::Bad:
- Foo is version 0.02, but must be greater than version 0.03
-EOF
- }
+ use_ok_warnings(
+ 'Foo::Conflicts::Bad',
+ ['Foo::Conflicts::Bad', 'Foo::Two', '0.02', '0.02'],
+ ['Foo::Conflicts::Bad', 'Foo', '0.02', '0.03'],
+ );
is_deeply(
[ Foo::Conflicts::Bad->calculate_conflicts ],
@@ -62,19 +71,12 @@ EOF
}
{
- {
- my $warnings;
- local $SIG{__WARN__} = sub { $warnings .= $_[0] };
- use_ok('Bar::Conflicts::Bad');
- is($warnings, <<'EOF', "got correct runtime warnings");
-Conflict detected for Bar::Conflicts::Bad2:
- Bar::Two is version 0.02, but must be greater than version 0.02
-Conflict detected for Bar::Conflicts::Bad:
- Bar::Two is version 0.02, but must be greater than version 0.02
-Conflict detected for Bar::Conflicts::Bad:
- Bar is version 0.02, but must be greater than version 0.03
-EOF
- }
+ use_ok_warnings(
+ 'Bar::Conflicts::Bad',
+ ['Bar::Conflicts::Bad2', 'Bar::Two', '0.02', '0.02'],
+ ['Bar::Conflicts::Bad', 'Bar::Two', '0.02', '0.02'],
+ ['Bar::Conflicts::Bad', 'Bar', '0.02', '0.03'],
+ );
is_deeply(
[ Bar::Conflicts::Bad->calculate_conflicts ],
diff --git a/t/03-dist.t b/t/03-dist.t
index 463c12f..277ccfd 100644
--- a/t/03-dist.t
+++ b/t/03-dist.t
@@ -5,6 +5,21 @@ use Test::More;
use Test::Fatal;
use lib 't/lib/03';
+sub use_ok_warnings {
+ 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] };
+ use_ok($class);
+ }
+ @warnings = sort @warnings;
+
+ is_deeply(\@warnings, \@conflicts, "correct runtime warnings for $class");
+}
+
{
use_ok('Foo::Conflicts::Good');
is_deeply(
@@ -21,17 +36,11 @@ use lib 't/lib/03';
}
{
- {
- my $warnings;
- local $SIG{__WARN__} = sub { $warnings .= $_[0] };
- use_ok('Foo::Conflicts::Bad');
- is($warnings, <<'EOF', "got correct runtime warnings");
-Conflict detected for Foo:
- Foo::Two is version 0.02, but must be greater than version 0.02
-Conflict detected for Foo:
- Foo is version 0.02, but must be greater than version 0.03
-EOF
- }
+ use_ok_warnings(
+ 'Foo::Conflicts::Bad',
+ ['Foo', 'Foo::Two', '0.02', '0.02'],
+ ['Foo', 'Foo', '0.02', '0.03'],
+ );
is_deeply(
[ Foo::Conflicts::Bad->calculate_conflicts ],
@@ -65,19 +74,12 @@ EOF
}
{
- {
- my $warnings;
- local $SIG{__WARN__} = sub { $warnings .= $_[0] };
- use_ok('Bar::Conflicts::Bad');
- is($warnings, <<'EOF', "got correct runtime warnings");
-Conflict detected for Bar:
- Bar::Two is version 0.02, but must be greater than version 0.02
-Conflict detected for Bar:
- Bar::Two is version 0.02, but must be greater than version 0.02
-Conflict detected for Bar:
- Bar is version 0.02, but must be greater than version 0.03
-EOF
- }
+ use_ok_warnings(
+ 'Bar::Conflicts::Bad',
+ ['Bar', 'Bar::Two', '0.02', '0.02'],
+ ['Bar', 'Bar::Two', '0.02', '0.02'],
+ ['Bar', 'Bar', '0.02', '0.03'],
+ );
is_deeply(
[ Bar::Conflicts::Bad->calculate_conflicts ],
diff --git a/t/06-runtime.t b/t/06-runtime.t
index 6e429b7..e8a18cc 100644
--- a/t/06-runtime.t
+++ b/t/06-runtime.t
@@ -4,35 +4,35 @@ use warnings;
use Test::More;
use lib 't/lib/06';
-sub warnings_ok {
- my ($class, $expected) = @_;
+sub use_ok_warnings {
+ my ($class, @conflicts) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
- my $warnings;
- local $SIG{__WARN__} = sub { $warnings .= $_[0] };
- use_ok($class);
- is($warnings, $expected, "correct runtime warnings for $class");
+ @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] };
+ use_ok($class);
+ }
+ @warnings = sort @warnings;
+
+ is_deeply(\@warnings, \@conflicts, "correct runtime warnings for $class");
}
-warnings_ok('Foo', <<'WARNINGS');
-Conflict detected for Foo::Conflicts:
- Foo::Foo is version 0.01, but must be greater than version 0.01
-Conflict detected for Foo::Conflicts:
- Foo::Bar is version 0.01, but must be greater than version 0.01
-WARNINGS
-warnings_ok('Bar', <<'WARNINGS');
-Conflict detected for Bar::Conflicts:
- Bar::Baz::Bad is version 0.01, but must be greater than version 0.01
-Conflict detected for Bar::Conflicts:
- Bar::Foo::Bad is version 0.01, but must be greater than version 0.01
-Conflict detected for Bar::Conflicts:
- Bar::Foo is version 0.01, but must be greater than version 0.01
-Conflict detected for Bar::Conflicts:
- Bar::Bar::Bad is version 0.01, but must be greater than version 0.01
-Conflict detected for Bar::Conflicts:
- Bar::Bar is version 0.01, but must be greater than version 0.01
-Conflict detected for Bar::Conflicts:
- Bar::Quux::Bad is version 0.01, but must be greater than version 0.01
-WARNINGS
+use_ok_warnings(
+ 'Foo',
+ ['Foo::Conflicts', 'Foo::Foo', '0.01', '0.01'],
+ ['Foo::Conflicts', 'Foo::Bar', '0.01', '0.01'],
+);
+use_ok_warnings(
+ '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(scalar(grep { ref($_) eq 'ARRAY' && @$_ > 1 && ref($_->[1]) eq 'HASH' }
@INC),