mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 16:35:40 -04:00
Merge pull request #24 from perlbot/test-pr-run
Add test for core plugin and make it a PR to test actions on prs
This commit is contained in:
commit
eaebbef9f3
3 changed files with 45 additions and 2 deletions
2
cpanfile
2
cpanfile
|
@ -45,8 +45,6 @@ requires "Net::DNS";
|
||||||
requires "Net::INET6Glue::INET_is_INET6";
|
requires "Net::INET6Glue::INET_is_INET6";
|
||||||
requires "Parse::RecDescent";
|
requires "Parse::RecDescent";
|
||||||
requires "Path::Tiny";
|
requires "Path::Tiny";
|
||||||
requires "Paws";
|
|
||||||
requires "Paws::Credential::Explicit";
|
|
||||||
requires "POE";
|
requires "POE";
|
||||||
requires "POE::Component::IRC";
|
requires "POE::Component::IRC";
|
||||||
requires "POE::Component::IRC::Common";
|
requires "POE::Component::IRC::Common";
|
||||||
|
|
|
@ -29,10 +29,12 @@ sub {
|
||||||
if ( Module::CoreList->can('deprecated_in') ) {
|
if ( Module::CoreList->can('deprecated_in') ) {
|
||||||
my $dep = Module::CoreList->deprecated_in($module);
|
my $dep = Module::CoreList->deprecated_in($module);
|
||||||
print " and deprecated in $dep" if $dep;
|
print " and deprecated in $dep" if $dep;
|
||||||
|
return 'handled';
|
||||||
}
|
}
|
||||||
if ( Module::CoreList->can('removed_from') ) {
|
if ( Module::CoreList->can('removed_from') ) {
|
||||||
my $rem = Module::CoreList->removed_from($module);
|
my $rem = Module::CoreList->removed_from($module);
|
||||||
print " and removed from $rem" if $rem;
|
print " and removed from $rem" if $rem;
|
||||||
|
return 'handled';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -42,10 +44,12 @@ sub {
|
||||||
print 'Found', scalar @modules, ':', join ',',
|
print 'Found', scalar @modules, ':', join ',',
|
||||||
map { $_ . ' in ' . Module::CoreList->first_release($_) }
|
map { $_ . ' in ' . Module::CoreList->first_release($_) }
|
||||||
@modules;
|
@modules;
|
||||||
|
return 'handled';
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Module $module does not appear to be in core. Perhaps capitalization matters or try using the 'cpan' command to search for it.";
|
print "Module $module does not appear to be in core. Perhaps capitalization matters or try using the 'cpan' command to search for it.";
|
||||||
|
return 'handled';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
41
t/core-plugin.t
Normal file
41
t/core-plugin.t
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use Test::More;
|
||||||
|
use Test::Differences qw/ eq_or_diff /;
|
||||||
|
use Capture::Tiny qw/capture/;
|
||||||
|
use lib '.';
|
||||||
|
my $sub = require plugins::core;
|
||||||
|
|
||||||
|
sub make_said
|
||||||
|
{
|
||||||
|
my ($body, $who, $server, $channel) = @_;
|
||||||
|
|
||||||
|
my @args = split /\s+/, $body;
|
||||||
|
my $said = {
|
||||||
|
body => $body,
|
||||||
|
recommended_args => \@args,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check
|
||||||
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
my ( $body, $want, $res, $blurb ) = @_;
|
||||||
|
|
||||||
|
my $said = make_said($body);
|
||||||
|
my ($out, $err, @result) = capture {
|
||||||
|
$sub->( $said );
|
||||||
|
};
|
||||||
|
|
||||||
|
return eq_or_diff( $err, "", "no errors" )
|
||||||
|
&& eq_or_diff(\@result, $res, "Result is correct")
|
||||||
|
&& eq_or_diff( $out, $want, $blurb );
|
||||||
|
}
|
||||||
|
|
||||||
|
check("", "usage: core Module::Here", ["handled"], "usage help");
|
||||||
|
check("CGI", "CGI Added to perl core as of 5.004 and deprecated in 5.019007", ["handled"], "deprecated");
|
||||||
|
check("Data::Dumper", "Data::Dumper Added to perl core as of 5.005", ["handled"], "never gonna give it up");
|
||||||
|
done_testing();
|
Loading…
Add table
Reference in a new issue