doherty / dist-zilla-plugin-test-cpan-changes Goto Github PK
View Code? Open in Web Editor NEWrelease tests for your changelog
Home Page: http://metacpan.org/release/Dist-Zilla-Plugin-Test-CPAN-Changes/
release tests for your changelog
Home Page: http://metacpan.org/release/Dist-Zilla-Plugin-Test-CPAN-Changes/
Observed behavior: Test fails to pass on valid Changes file
Expected behavior: Changes file should pass the test
Package version: 0.02
Given the following Changes file:
0.02 2015-09-16 18:39:40-05:00 America/Chicago
- Added support for multiple WSDL files. Removed custom SOAP transport support in SOAPClient Role
in favor of support for a transport hook
(cf https://metacpan.org/pod/XML::Compile::Transport#Handlers). When the same method name is
present in two WSDL's (or more accurately, under two WSDL service definitions) the method will
be made available under each service by prepending the service name and '#' to the method name,
e.g. for method "GetAThing" under services "Service1" and "Service2", the caller will be unable
to do $obj->call('GetAThing', %params), but must instead call 'Service1#GetAThing' or
'Service2#GetAThing'.
0.01 2015-09-08 20:55:55-05:00 America/Chicago
- Initial release. Basic Candidate class provided. Roles provided:
* SendCandidate
* JSONEncoded
* XMLEncoded
* WithUserAgent'
t/release-changes_has_content.t fails:
1..2
# Checking Changes
ok 1 - Changes file exists
not ok 2 - Changes has content for 0.02
# Failed test 'Changes has content for 0.02'
# at t/release-changes_has_content.t line 22.
# Looks like you failed 1 test of 2.
However, Test::CPAN::Changes passes the file:
perl -e 'use Test::More; use Test::CPAN::Changes; changes_file_ok("Changes", {version => "0.02"}); done_testing;'
ok 1 - Changes is loadable
ok 2 - Changes contains at least one release
ok 3 - Changes contains valid release dates
ok 4 - Changes contains valid version numbers
ok 5 - Changes has an entry for the current version, 0.02
ok 6 - entry for the current version, 0.02, has content
1..6
Test::CPAN::Changes::changes_file_ok accepts version, e. g.:
changes_file_ok( 'Changes', { version => '0.003' } );
In such a case test verifies that Changes file has an entry for that version. It would be useful if the plugin generates test which calls changes_file_ok with two arguments, e. g.:
--- lib/Dist/Zilla/Plugin/Test/CPAN/Changes.pm.ORIG 2015-06-15 23:10:27.000000000 +0300
+++ lib/Dist/Zilla/Plugin/Test/CPAN/Changes.pm 2015-06-16 00:10:52.309510386 +0300
@@ -61,8 +61,10 @@
my $content = ${$self->section_data($file)};
my $changes_filename = $self->changelog;
+ my $version = $self->zilla->version;
$content =~ s/CHANGESFILENAME/$changes_filename/;
+ $content =~ s/VERWSION/$version/;
$self->add_file( Dist::Zilla::File::InMemory->new(
name => $file,
@@ -105,6 +107,6 @@
use Test::More 0.96 tests => 2;
use_ok('Test::CPAN::Changes');
subtest 'changes_ok' => sub {
- changes_file_ok('CHANGESFILENAME');
+ changes_file_ok('CHANGESFILENAME', {version => "VERSION"});
};
done_testing();
If mandatory version checking is not acceptable, it can be made conditional from within dist.ini
, e. g.:
[Test::CPAN::Changes]
check_version = 0
It will require a little bit more coding in the plugin:
--- lib/Dist/Zilla/Plugin/Test/CPAN/Changes.pm.ORIG 2015-06-15 23:10:27.000000000 +0300
+++ lib/Dist/Zilla/Plugin/Test/CPAN/Changes.pm 2015-06-16 00:30:30.796637435 +0300
@@ -48,6 +48,12 @@
default => 'Changes',
);
+has check_version => (
+ is => 'ro',
+ isa => 'Bool',
+ default => 1,
+);
+
=for Pod::Coverage gather_files register_prereqs
=cut
@@ -61,8 +67,10 @@
my $content = ${$self->section_data($file)};
my $changes_filename = $self->changelog;
+ my $version = $self->zilla->version;
$content =~ s/CHANGESFILENAME/$changes_filename/;
+ $content =~ s/VERSION/$self->check_version ? "'$version'" : "undef"/e;
$self->add_file( Dist::Zilla::File::InMemory->new(
name => $file,
@@ -105,6 +113,6 @@
use Test::More 0.96 tests => 2;
use_ok('Test::CPAN::Changes');
subtest 'changes_ok' => sub {
- changes_file_ok('CHANGESFILENAME');
+ changes_file_ok('CHANGESFILENAME', {version => VERSION});
};
done_testing();
dzil test
Required plugin ChangesTests isn't installed.
Run 'dzil authordeps' to see a list of all required plugins.
You can pipe the list to your CPAN client to install or update them:
dzil authordeps | cpanm
perl -MDist::Zilla::Plugin::Test::CPAN::Changes -e 'print "$Dist::Zilla::Plugin::Test::CPAN::Changes::VERSION\n"'
0.004
grep ChangesTests dist.ini
[ChangesTests]
Calling use_ok
instead of eval
doesn't really give you much.
If the module is not installed, then you're going to get an anomalous failure anyway as a consequence:
Undefined subroutine &main::changes_file_ok called at xt/release/cpan-changes.t line 9.
Additionally, using use_ok
inhibits any sort of prereq detection that relies on being able to statically parse use requirements.
Its simpler here to just use Test::CPAN::Changes
and at least that way the compile time error is straight forward and there are no subsequent bogus errors one has to correct.
( Which is what all the other Test:: plugins are now doing )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.