Skip Menu |

This queue is for tickets about the CPAN-Changes CPAN distribution.

Report information
The Basics
Id: 87576
Status: open
Priority: 0/
Queue: CPAN-Changes

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.20
  • 0.21
  • 0.22
Fixed in: (no value)



Subject: CPAN-Changes test suite doesn't have a test to check Test::CPAN::Changes actually works
There is no test in the test suite to check that: 1. Test::CPAN::Changes gives a PASS result to change logs conforming to the CPAN::Changes::Spec. 2. Test::CPAN::Changes gives a FAIL result to change logs not conforming to the CPAN::Changes::Spec. The attached file remedies that. Running this file shows that Test::CPAN::Changes has the following problems: 1. It produces a PASS result for Changes files containing versions "1.", ".1", "v1.2" and "1.2.3", even though they do not conform to CPAN::Meta::Spec. 2. It produces a PASS for Changes files containing the date "002000-01-14", even though that does not conform to W3CDTF. (IIRC, it conforms to ISO-8601, which is a superset of W3CDTF.) 3. It warns about the date "Sat Jan 8 00:00:00 GMT 2000", which does not conform to W3CDTF, but the result is still reported as a PASS. Also interesting to note, but probably sensible behaviour: it warns about the date "2000-01-09 00:00:00", even though that technically complies with the CPAN::Changes::Spec if you assume that "00:00:00" is a release note!
Subject: test-cpan-changes.t
=pod =head1 PURPOSE This test file tests that Test::CPAN::Changes correctly detects Changes files that do/don't conform to the CPAN::Changes::Spec. =head1 AUTHOR Toby Inkster E<lt>tobyink@cpan.orgE<gt>. =cut use strict; use warnings; use Test::Tester; use Test::More 0.96; use Test::CPAN::Changes; use File::Temp 'tempfile'; my $str; while (<DATA>) { unless (/^~~ (\S+): (.+)/) { $str .= $_; next; } my $type = $1; my $msg = $2; # Create a temp file and test it using Test::CPAN::Changes my ($fh, $filename) = tempfile; print {$fh} $str; close $fh; my (undef, @results) = run_tests(sub { changes_file_ok($filename) }); if ($type =~ /Date/) { # We're testing that Test::CPAN::Changes detected an invalid date ok(!$results[2]{ok}, "$type: $msg"); } elsif ($type =~ /Version/) { # We're testing that Test::CPAN::Changes detected an invalid version number ok(!$results[3]{ok}, "$type: $msg"); } elsif ($type =~ /OK/) { # We're testing that Test::CPAN::Changes accepted the changelog ok($results[1]{ok} && $results[2]{ok} && $results[3]{ok}, "$type: $msg"); } else { BAIL_OUT("something wrong in __DATA__"); } # Clean up $str = ''; unlink $filename; } done_testing; __DATA__ 1.23_04_05 2000-01-01 ~~ Version: "1.23_04_05" does not conform to CPAN::Meta::Spec's version format 1. 2000-01-02 ~~ Version: "1." does not conform to CPAN::Meta::Spec's version format .1 2000-01-03 ~~ Version: ".1" does not conform to CPAN::Meta::Spec's version format v1.2 2000-01-04 ~~ Version: "v1.2" does not conform to CPAN::Meta::Spec's version format 1.2.3 2000-01-05 ~~ Version: "1.2.3" does not conform to CPAN::Meta::Spec's version format v1.2_3_4 2000-01-06 ~~ Version: "v1.2_3_4" does not conform to CPAN::Meta::Spec's version format 1.200 7-1-2000 ~~ Date: "7-1-2000" does not conform to W3CDTF 1.200 Sat Jan 8 00:00:00 GMT 2000 ~~ Date: "Sat" does not conform to W3CDTF (note that "Jan 8 00:00:00 GMT 2000" should technically be considered the release note!) 1.200 2000-01-09 00:00:00 ~~ OK: "2000-01-09" conforms to W3CDTF (note that "00:00:00" should technically be considered the release note!) 1.200 2000-01 ~~ OK: "2000-01" conforms to W3CDTF 1.200 2000 ~~ OK: "2000" conforms to W3CDTF 1.200 2000-01-12T00:00:00.00000000000000000000Z ~~ OK: "2000-01-13T00:00:00.00000000000000000000Z" conforms to W3CDTF 1.200 00-01-13 ~~ Date: "00-01-13" does not conform to W3CDTF 1.200 002000-01-14 ~~ Date: "002000-01-14" does not conform to W3CDTF 1.234 2000-01-15 ~~ OK: "1.234" conforms to CPAN::Meta::Spec's version format 1.23_04 2000-01-16 ~~ OK: "1.23_04" conforms to CPAN::Meta::Spec's version format v1.2.3 2000-01-17 ~~ OK: "v1.2.3" conforms to CPAN::Meta::Spec's version format v1.2_3 2000-01-18 ~~ OK: "v1.2_3" conforms to CPAN::Meta::Spec's version format v1.2.3.4 2000-01-19 ~~ OK: "v1.2.3.4" conforms to CPAN::Meta::Spec's version format v1.2.3_4 2000-01-20 ~~ OK: "v1.2.3_4" conforms to CPAN::Meta::Spec's version format v2000.01.21 2000-01-21 ~~ OK: "v2000.01.21" conforms to CPAN::Meta::Spec's version format v1.2000.01.22 2000-01-21 ~~ OK: "v1.2000.01.22" conforms to CPAN::Meta::Spec's version format (even though it is discouraged)
On Sat Aug 03 19:04:19 2013, TOBYINK wrote: Show quoted text
> There is no test in the test suite to check that: > > 1. Test::CPAN::Changes gives a PASS result to change logs conforming > to the CPAN::Changes::Spec. > > 2. Test::CPAN::Changes gives a FAIL result to change logs not > conforming to the CPAN::Changes::Spec. > > The attached file remedies that. > > Running this file shows that Test::CPAN::Changes has the following > problems: > > 1. It produces a PASS result for Changes files containing versions > "1.", ".1", "v1.2" and "1.2.3", even though they do not conform to > CPAN::Meta::Spec. > > 2. It produces a PASS for Changes files containing the date "002000- > 01-14", even though that does not conform to W3CDTF. (IIRC, it > conforms to ISO-8601, which is a superset of W3CDTF.) > > 3. It warns about the date "Sat Jan 8 00:00:00 GMT 2000", which does > not conform to W3CDTF, but the result is still reported as a PASS. > > Also interesting to note, but probably sensible behaviour: it warns > about the date "2000-01-09 00:00:00", even though that technically > complies with the CPAN::Changes::Spec if you assume that "00:00:00" is > a release note!
A few things: * This test really needed to be written, so thank you. * Version parsing is handled by version.pm -- we use its "lax" parsing in order to handle the largest number of acceptable values (within reason). Perhaps the spec should be updated to be more specific about how we handle versions -- CPAN::Meta::Spec is perhaps too strict for our needs. * The latest CPAN::Changes spec (0.03) allows the "T" marker to be optional in W3CDTF dates * We accept a number of date formats, but warn when they don't match the W3CDTF. The new Kwalitee Site will have this "warnings" notion soon. * With that in mind, if you can tidy things up based on the feedback above and mark the failing tests as "TODO", then I'd be happy to add the test in directly. Otherwise it will have to wait until I get a few more tuits to do it myself :) In any event, thanks again. -Brian