have disttest on release include xt tests and RELEASE_TESTING=1
[p5sagit/Distar.git] / lib / Distar.pm
index f4336ac..6bd4db2 100644 (file)
@@ -6,10 +6,7 @@ use base qw(Exporter);
 use ExtUtils::MakeMaker ();
 use ExtUtils::MM ();
 
-use Config;
-use File::Spec;
-
-our $VERSION = '0.001000';
+our $VERSION = '0.002000';
 $VERSION = eval $VERSION;
 
 my $MM_VER = eval $ExtUtils::MakeMaker::VERSION;
@@ -38,7 +35,7 @@ our @Manifest = (
   'xt' => '.t',
   'xt/lib' => '.pm',
   '' => qr{[^/]*\.PL},
-  '' => qr{Changes|MANIFEST|README|META\.yml},
+  '' => qr{Changes|MANIFEST|README|LICENSE|META\.yml},
   'maint' => qr{[^.].*},
 );
 
@@ -46,15 +43,12 @@ sub manifest_include {
   push @Manifest, @_;
 }
 
-my $readme_generator = <<'README';
-       pod2text $(VERSION_FROM) >$(DISTVNAME)/README
-       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-to-manifest README
-README
 sub readme_generator {
-    $readme_generator = shift;
+  die "readme_generator unsupported" if @_ && $_[0];
 }
 
 sub write_manifest_skip {
+  my ($mm) = @_;
   my @files = @Manifest;
   my @parts;
   while (my ($dir, $spec) = splice(@files, 0, 2)) {
@@ -67,7 +61,9 @@ sub write_manifest_skip {
           : die "spec must be string or regexp, was: ${spec} (${\ref $spec})");
     push @parts, $re;
   }
-  my $final = '^(?!'.join('|', map "${_}\$", @parts).')';
+  my $dist_name = $mm->{DISTNAME};
+  my $include = join '|', map "${_}\$", @parts;
+  my $final = "^(?:\Q$dist_name\E-v?[0-9_.]+/|(?!$include))";
   open my $skip, '>', 'MANIFEST.SKIP'
     or die "can't open MANIFEST.SKIP: $!";
   print $skip "${final}\n";
@@ -97,7 +93,7 @@ sub write_manifest_skip {
 
   sub flush {
     my $self = shift;
-    Distar::write_manifest_skip();
+    Distar::write_manifest_skip($self);
     $self->SUPER::flush(@_);
   }
 
@@ -115,8 +111,9 @@ END
     $dist_test .= <<'END';
 preflight:
        $(ABSPERLRUN) Distar/helpers/preflight $(VERSION)
-release: preflight
-       $(MAKE) disttest
+releasetest:
+       $(MAKE) disttest RELEASE_TESTING=1 TEST_FILES="$(TEST_FILES)"
+release: preflight releasetest
        $(RM_RF) $(DISTVNAME)
        $(MAKE) $(DISTVNAME).tar$(SUFFIX)
        git commit -a -m "Release commit for $(VERSION)"
@@ -124,15 +121,17 @@ release: preflight
        cpan-upload $(DISTVNAME).tar$(SUFFIX)
        git push origin v$(VERSION) HEAD
 distdir: readmefile
-readmefile: create_distdir
-END
-    . $readme_generator . <<'END';
+readmefile: create_distdir $(DISTVNAME)/README
+       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-to-manifest README
+$(DISTVNAME)/README: $(VERSION_FROM)
+       $(NOECHO) $(MKPATH) $(DISTVNAME)
+       pod2text $(VERSION_FROM) >$(DISTVNAME)/README
 disttest: distmanicheck
 distmanicheck: create_distdir
        cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"
 nextrelease:
        $(ABSPERLRUN) Distar/helpers/add-changelog-heading $(VERSION) Changes
-       git add -p Changes
+       GIT_DIFF_OPTS=-u`$(ABSPERLRUN) Distar/helpers/changelog-context $(VERSION) Changes` git add -p Changes
 refresh:
        cd Distar && git pull
        rm Makefile