📄 40_cpanplus-internals-report.t
字号:
### make sure we can find our conf.pl fileBEGIN { use FindBin; require "$FindBin::Bin/inc/conf.pl";}use strict;use CPANPLUS::Backend;use CPANPLUS::Internals::Constants::Report;my $send_tests = 55;my $query_tests = 8;my $total_tests = $send_tests + $query_tests;use Test::More 'no_plan';use Module::Load::Conditional qw[can_load];use FileHandle;use Data::Dumper;use constant NOBODY => 'nobody@xs4all.nl';my $conf = gimme_conf();my $CB = CPANPLUS::Backend->new( $conf );my $ModName = TEST_CONF_MODULE;my $ModPrereq = TEST_CONF_PREREQ;### divide by many -- possibly ~0 is unsigned, and we cause an overflow,### as happens to version.pm 0.7203 among others.my $HighVersion = ~0/1000;my $Mod = $CB->module_tree($ModName);my $int_ver = $CPANPLUS::Internals::VERSION;### explicitly enable testing if possible ###$CB->configure_object->set_conf(cpantest =>1) if $ARGV[0];my $map = { all_ok => { buffer => '', # output from build process failed => 0, # indicate failure match => [qw|/PASS/|], # list of regexes for the output check => 0, # check if callbacks got called? }, skipped_test => { buffer => '', failed => 0, match => ['/PASS/', '/tests for this module were skipped during this build/', ], check => 0, skiptests => 1, # did we skip the tests? }, missing_prereq => { buffer => missing_prereq_buffer(), failed => 1, match => ['/The comments above are created mechanically/', '/computer-generated error report/', '/Below is the error stack from stage/', '/test suite seem to fail without these modules/', '/floo/', '/FAIL/', '/make test/', ], check => 1, }, missing_tests => { buffer => missing_tests_buffer(), failed => 1, match => ['/The comments above are created mechanically/', '/computer-generated error report/', '/Below is the error stack from stage/', '/RECOMMENDATIONS/', '/UNKNOWN/', '/make test/', ], check => 0, }, perl_version_too_low_mm => { buffer => perl_version_too_low_buffer_mm(), failed => 1, match => ['/This distribution has been tested/', '/http://testers.cpan.org/', '/NA/', ], check => 0, }, perl_version_too_low_build1 => { buffer => perl_version_too_low_buffer_build(1), failed => 1, match => ['/This distribution has been tested/', '/http://testers.cpan.org/', '/NA/', ], check => 0, }, perl_version_too_low_build2 => { buffer => perl_version_too_low_buffer_build(2), failed => 1, match => ['/This distribution has been tested/', '/http://testers.cpan.org/', '/NA/', ], check => 0, }, prereq_versions_too_low => { ### set the prereq version incredibly high pre_hook => sub { my $mod = shift; my $clone = $mod->clone; $clone->status->prereqs({ $ModPrereq => $HighVersion }); return $clone; }, failed => 1, match => ['/This distribution has been tested/', '/http://testers.cpan.org/', '/NA/', ], check => 0, }, prereq_not_on_cpan => { pre_hook => sub { my $mod = shift; my $clone = $mod->clone; $clone->status->prereqs( { TEST_CONF_INVALID_MODULE, 0 } ); return $clone; }, failed => 1, match => ['/This distribution has been tested/', '/http://testers.cpan.org/', '/NA/', ], check => 0, }, };### test config settings { for my $opt ( qw[cpantest cpantest_mx] ) { my $warnings; local $SIG{__WARN__} = sub { $warnings .= "@_" }; my $org = $conf->get_conf( $opt ); ok( $conf->set_conf( $opt => $$ ), "Setting option $opt to $$" ); is( $conf->get_conf( $opt ), $$, " Retrieved properly" ); ok( $conf->set_conf( $opt => $org ), " Option $opt set back to original" ); ok( !$warnings, " No warnings" ); }}### test constants ###{ { my $to = CPAN_MAIL_ACCOUNT->('foo'); is( $to, 'foo@cpan.org', "Got proper mail account" ); } { ok(RELEVANT_TEST_RESULT->($Mod),"Test is relevant" ); ### test non-relevant tests ### my $cp = $Mod->clone; $cp->module( $Mod->module . '::' . ($^O eq 'beos' ? 'MSDOS' : 'Be') ); ok(!RELEVANT_TEST_RESULT->($cp),"Test is irrelevant"); } { my $support = "it works!"; my @support = ( "No support for OS", "OS unsupported", "os unsupported", ); ok(!UNSUPPORTED_OS->($support), "OS supported"); ok( UNSUPPORTED_OS->($_), "OS not supported") for(@support); } { ok(PERL_VERSION_TOO_LOW->( perl_version_too_low_buffer_mm() ), "Perl version too low" ); ok(PERL_VERSION_TOO_LOW->( perl_version_too_low_buffer_build(1) ), "Perl version too low" ); ok(PERL_VERSION_TOO_LOW->( perl_version_too_low_buffer_build(2) ), "Perl version too low" ); ok(!PERL_VERSION_TOO_LOW->('foo'), " Perl version adequate" ); } { my $tests = "test.pl"; my @none = ( "No tests defined for Foo extension.", "'No tests defined for Foo::Bar extension.'", "'No tests defined.'", ); ok(!NO_TESTS_DEFINED->($tests), "Tests defined"); ok( NO_TESTS_DEFINED->($_), "No tests defined") for(@none); } { my $fail = 'MAKE TEST'; my $unknown = 'foo'; is( TEST_FAIL_STAGE->($fail), lc $fail, "Proper test fail stage found" ); is( TEST_FAIL_STAGE->($unknown), 'fetch', "Proper test fail stage found" ); } ### test missing prereqs { my $str = q[Can't locate Foo/Bar.pm in @INC]; ### standard test { my @list = MISSING_PREREQS_LIST->( $str ); is( scalar(@list), 1, " List of missing prereqs found" ); is( $list[0], 'Foo::Bar', " Proper prereq found" ); } ### multiple mentions of same prereq { my @list = MISSING_PREREQS_LIST->( $str . $str ); is( scalar(@list), 1, " 1 result for multiple mentions" ); is( $list[0], 'Foo::Bar', " Proper prereq found" ); } } { # cp version, author my $header = REPORT_MESSAGE_HEADER->($int_ver,'foo'); ok( $header, "Test header generated" ); like( $header, qr/Dear foo,/, " Proper content found" ); like( $header, qr/puter-gen/, " Proper content found" ); like( $header, qr/CPANPLUS,/, " Proper content found" ); like( $header, qr/ments may/, " Proper content found" ); } { # stage, buffer my $header = REPORT_MESSAGE_FAIL_HEADER->('test','buffer'); ok( $header, "Test header generated" ); like( $header, qr/uploading/, " Proper content found" ); like( $header, qr/RESULTS:/, " Proper content found" ); like( $header, qr/stack/, " Proper content found" ); like( $header, qr/buffer/, " Proper content found" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -