From c1d96ea5ce0260890f0e496438ab762728877154 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 13 Jan 2011 01:17:24 -0600 Subject: update tests to check for runtime warnings --- t/02-conflicts.t | 28 ++++++++++++++++++++++++++-- t/03-dist.t | 28 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/t/02-conflicts.t b/t/02-conflicts.t index 7303be2..e788815 100644 --- a/t/02-conflicts.t +++ b/t/02-conflicts.t @@ -20,7 +20,18 @@ use lib 't/lib/02'; } { - use_ok('Foo::Conflicts::Bad'); + { + 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 + } + is_deeply( [ Foo::Conflicts::Bad->calculate_conflicts ], [ @@ -51,7 +62,20 @@ use lib 't/lib/02'; } { - use_ok('Bar::Conflicts::Bad'); + { + 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 + } + is_deeply( [ Bar::Conflicts::Bad->calculate_conflicts ], [ diff --git a/t/03-dist.t b/t/03-dist.t index 65b08db..463c12f 100644 --- a/t/03-dist.t +++ b/t/03-dist.t @@ -21,7 +21,18 @@ use lib 't/lib/03'; } { - use_ok('Foo::Conflicts::Bad'); + { + 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 + } + is_deeply( [ Foo::Conflicts::Bad->calculate_conflicts ], [ @@ -54,7 +65,20 @@ use lib 't/lib/03'; } { - use_ok('Bar::Conflicts::Bad'); + { + 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 + } + is_deeply( [ Bar::Conflicts::Bad->calculate_conflicts ], [ -- cgit v1.2.3-54-g00ecf