summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-02-08 11:50:31 +0000
committerNicholas Clark <nick@ccl4.org>2011-07-01 13:24:32 +0200
commit019c1b48d0afe02f6980be8f95bef63565035ccc (patch)
tree3700b070ed19337c36ae858c4ccc5e7c2e9aea90
parent2be180df812eb531ae3e5b0db16885ebfd931194 (diff)
downloadperl-019c1b48d0afe02f6980be8f95bef63565035ccc.tar.gz
Convert B::Lint's test to Test::PerlRun and Test::More from test.pl
-rw-r--r--dist/B-Lint/t/lint.t35
1 files changed, 15 insertions, 20 deletions
diff --git a/dist/B-Lint/t/lint.t b/dist/B-Lint/t/lint.t
index 7317b1d746..cb56d3026d 100644
--- a/dist/B-Lint/t/lint.t
+++ b/dist/B-Lint/t/lint.t
@@ -2,32 +2,31 @@
BEGIN {
unshift @INC, 't';
- push @INC, "../../t";
require Config;
if ( ( $Config::Config{'extensions'} !~ /\bB\b/ ) ) {
print "1..0 # Skip -- Perl configured without B module\n";
exit 0;
}
- require 'test.pl';
}
use strict;
use warnings;
-plan tests => 29;
+use Test::More tests => 56;
+use Test::PerlRun qw(perlrun perlrun_stderr_like);
# Runs a separate perl interpreter with the appropriate lint options
# turned on
sub runlint ($$$;$) {
my ( $opts, $prog, $result, $testname ) = @_;
- my $res = runperl(
+ my ($out, $err) = perlrun({
switches => ["-MO=Lint,$opts"],
- prog => $prog,
- stderr => 1,
- );
- $res =~ s/-e syntax OK\n$//;
- local $::Level = $::Level + 1;
- is( $res, $result, $testname || $opts );
+ code => $prog,
+ });
+ $err =~ s/-e syntax OK\n$//;
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ is( $err, $result, $testname || $opts );
+ is( $out, '', 'nothing on STDOUT' );
}
runlint 'magic-diamond', 'while(<>){}', <<'RESULT';
@@ -125,22 +124,18 @@ RESULT
# Check for backwards-compatible plugin support. This was where
# preloaded mdoules would register themselves with B::Lint.
- my $res = runperl(
+ perlrun_stderr_like({
switches => ["-MB::Lint"],
- prog =>
+ code =>
'BEGIN{B::Lint->register_plugin(X=>[q[x]])};use O(qw[Lint x]);sub X::match{warn qq[X ok.\n]};dummy()',
- stderr => 1,
- );
- like( $res, qr/X ok\./, 'Lint legacy plugin' );
+ }, qr/X ok\./, 'Lint legacy plugin' );
}
{
# Check for Module::Plugin support
- my $res = runperl(
+ perlrun_stderr_like({
switches => [ '-It/pluglib', '-MO=Lint,none' ],
- prog => 1,
- stderr => 1,
- );
- like( $res, qr/Module::Pluggable ok\./, 'Lint uses Module::Pluggable' );
+ code => 1,
+ }, qr/Module::Pluggable ok\./, 'Lint uses Module::Pluggable' );
}