[Bps-public-commit] rt-extension-onetimeto branch, master, updated. 1.03

Alex Vandiver alexmv at bestpractical.com
Wed Jan 3 04:09:19 EST 2018


The branch, master has been updated
       via  c7d52c7a6db32d292d8bafe319d26961bb4f130b (commit)
       via  baf6c70896496cc6df0bd82b242bab3363cecb51 (commit)
       via  bbae9e0d519219c6361d9020c680a57e3b61b7c0 (commit)
      from  fc13fdfd4e5077b676442a4c0daa09a19487f906 (commit)

Summary of changes:
 .gitignore                               |   3 +-
 Changes                                  |   3 +
 MANIFEST                                 |   7 +-
 MANIFEST.SKIP                            |   3 +-
 META.yml                                 |   8 +-
 Makefile.PL                              |  11 +++
 inc/Module/Install.pm                    |   2 +-
 inc/Module/Install/AuthorTests.pm        |  59 ++++++++++++++
 inc/Module/Install/Base.pm               |   2 +-
 inc/Module/Install/Can.pm                |   2 +-
 inc/Module/Install/Fetch.pm              |   2 +-
 inc/Module/Install/Include.pm            |   2 +-
 inc/Module/Install/Makefile.pm           |   2 +-
 inc/Module/Install/Metadata.pm           |   2 +-
 inc/Module/Install/Substitute.pm         | 131 +++++++++++++++++++++++++++++++
 inc/Module/Install/Win32.pm              |   2 +-
 inc/Module/Install/WriteAll.pm           |   2 +-
 lib/RT/Extension/OneTimeTo.pm            |   2 +-
 {t => xt}/basic.t                        |   5 +-
 {t => xt}/empty-update.t                 |   5 +-
 xt/lib/RT/Extension/OneTimeTo/Test.pm.in |  21 +++++
 21 files changed, 257 insertions(+), 19 deletions(-)
 create mode 100644 inc/Module/Install/AuthorTests.pm
 create mode 100644 inc/Module/Install/Substitute.pm
 rename {t => xt}/basic.t (95%)
 rename {t => xt}/empty-update.t (80%)
 create mode 100644 xt/lib/RT/Extension/OneTimeTo/Test.pm.in

- Log -----------------------------------------------------------------
commit bbae9e0d519219c6361d9020c680a57e3b61b7c0
Author: Alex Vandiver <alex at chmrr.net>
Date:   Wed Jan 3 00:37:41 2018 -0800

    Mark tests as author tests
    
    These tests cannot run except in the presence of RT; skip them for most installs.

diff --git a/.gitignore b/.gitignore
index 9dc63f5..367a0ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,5 +8,5 @@ pm_to_blib
 .prove
 *.sw[po]
 cover_db/
-t/tmp
+/xt/tmp
 /MYMETA.*
diff --git a/MANIFEST b/MANIFEST
index 8823252..ce5897c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2,6 +2,7 @@ Changes
 html/Callbacks/OneTimeTo/Elements/ShowTransactionAttachments/MassageDisplayHeaders
 html/Callbacks/OneTimeTo/Ticket/Elements/UpdateCc/BeforeCc
 inc/Module/Install.pm
+inc/Module/Install/AuthorTests.pm
 inc/Module/Install/Base.pm
 inc/Module/Install/Can.pm
 inc/Module/Install/Fetch.pm
@@ -19,5 +20,5 @@ Makefile.PL
 MANIFEST			This list of files
 META.yml
 README
-t/basic.t
-t/empty-update.t
+xt/basic.t
+xt/empty-update.t
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index f3fbe30..4a92f11 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -62,4 +62,4 @@ Makefile$
 ^blib
 ^pm_to_blib
 ^MANIFEST\.
-^t/tmp
+^xt/tmp
diff --git a/META.yml b/META.yml
index b16cd03..1426e4a 100644
--- a/META.yml
+++ b/META.yml
@@ -18,7 +18,7 @@ no_index:
   directory:
     - html
     - inc
-    - t
+    - xt
 requires:
   perl: 5.10.1
 resources:
diff --git a/Makefile.PL b/Makefile.PL
index 9324a40..1e408bc 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,6 +4,8 @@ RTx('RT-Extension-OneTimeTo');
 
 repository('https://github.com/bestpractical/rt-extension-onetimeto');
 
+author_tests('xt');
+
 requires_rt '4.2.0';
 rt_too_new '4.6.0';
 
diff --git a/inc/Module/Install/AuthorTests.pm b/inc/Module/Install/AuthorTests.pm
new file mode 100644
index 0000000..c44931b
--- /dev/null
+++ b/inc/Module/Install/AuthorTests.pm
@@ -0,0 +1,59 @@
+#line 1
+package Module::Install::AuthorTests;
+
+use 5.005;
+use strict;
+use Module::Install::Base;
+use Carp ();
+
+#line 16
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+  $VERSION = '0.002';
+  $ISCORE  = 1;
+  @ISA     = qw{Module::Install::Base};
+}
+
+#line 42
+
+sub author_tests {
+  my ($self, @dirs) = @_;
+  _add_author_tests($self, \@dirs, 0);
+}
+
+#line 56
+
+sub recursive_author_tests {
+  my ($self, @dirs) = @_;
+  _add_author_tests($self, \@dirs, 1);
+}
+
+sub _wanted {
+  my $href = shift;
+  sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
+}
+
+sub _add_author_tests {
+  my ($self, $dirs, $recurse) = @_;
+  return unless $Module::Install::AUTHOR;
+
+  my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t';
+
+  # XXX: pick a default, later -- rjbs, 2008-02-24
+  my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests";
+     @dirs = grep { -d } @dirs;
+
+  if ($recurse) {
+    require File::Find;
+    my %test_dir;
+    File::Find::find(_wanted(\%test_dir), @dirs);
+    $self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir );
+  } else {
+    $self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs );
+  }
+}
+
+#line 107
+
+1;
diff --git a/t/basic.t b/xt/basic.t
similarity index 100%
rename from t/basic.t
rename to xt/basic.t
diff --git a/t/empty-update.t b/xt/empty-update.t
similarity index 100%
rename from t/empty-update.t
rename to xt/empty-update.t

commit baf6c70896496cc6df0bd82b242bab3363cecb51
Author: Alex Vandiver <alex at chmrr.net>
Date:   Wed Jan 3 00:55:16 2018 -0800

    Add a stub ::Test so tests work without RT in @INC

diff --git a/.gitignore b/.gitignore
index 367a0ce..99322be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,5 +8,6 @@ pm_to_blib
 .prove
 *.sw[po]
 cover_db/
+/xt/lib/RT/Extension/OneTimeTo/Test.pm
 /xt/tmp
 /MYMETA.*
diff --git a/MANIFEST b/MANIFEST
index ce5897c..3a81df5 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -12,6 +12,7 @@ inc/Module/Install/Metadata.pm
 inc/Module/Install/ReadmeFromPod.pm
 inc/Module/Install/RTx.pm
 inc/Module/Install/RTx/Runtime.pm
+inc/Module/Install/Substitute.pm
 inc/Module/Install/Win32.pm
 inc/Module/Install/WriteAll.pm
 inc/YAML/Tiny.pm
@@ -22,3 +23,4 @@ META.yml
 README
 xt/basic.t
 xt/empty-update.t
+xt/lib/RT/Extension/OneTimeTo/Test.pm.in
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index 4a92f11..83e3001 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -63,3 +63,4 @@ Makefile$
 ^pm_to_blib
 ^MANIFEST\.
 ^xt/tmp
+^xt/lib/RT/Extension/OneTimeTo/Test.pm$
diff --git a/META.yml b/META.yml
index 1426e4a..4ee38e9 100644
--- a/META.yml
+++ b/META.yml
@@ -19,6 +19,8 @@ no_index:
     - html
     - inc
     - xt
+  package:
+    - RT::Extension::OneTimeTo::Test
 requires:
   perl: 5.10.1
 resources:
diff --git a/Makefile.PL b/Makefile.PL
index 1e408bc..8b41129 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,6 +5,15 @@ RTx('RT-Extension-OneTimeTo');
 repository('https://github.com/bestpractical/rt-extension-onetimeto');
 
 author_tests('xt');
+no_index package => "RT::Extension::OneTimeTo::Test";
+
+my ($loaded) = ($INC{'RT.pm'} =~ /^(.*)[\\\/]/);
+my $lib_path = join( ' ', "$RT::LocalPath/lib", $loaded );
+substitute(
+    { RT_LIB_PATH => $lib_path },
+    { sufix => '.in' },
+    'xt/lib/RT/Extension/OneTimeTo/Test.pm',
+);
 
 requires_rt '4.2.0';
 rt_too_new '4.6.0';
diff --git a/inc/Module/Install/Substitute.pm b/inc/Module/Install/Substitute.pm
new file mode 100644
index 0000000..56af7fe
--- /dev/null
+++ b/inc/Module/Install/Substitute.pm
@@ -0,0 +1,131 @@
+#line 1
+package Module::Install::Substitute;
+
+use strict;
+use warnings;
+use 5.008; # I don't care much about earlier versions
+
+use Module::Install::Base;
+our @ISA = qw(Module::Install::Base);
+
+our $VERSION = '0.03';
+
+require File::Temp;
+require File::Spec;
+require Cwd;
+
+#line 89
+
+sub substitute
+{
+	my $self = shift;
+	$self->{__subst} = shift;
+	$self->{__option} = {};
+	if( UNIVERSAL::isa( $_[0], 'HASH' ) ) {
+		my $opts = shift;
+		while( my ($k,$v) = each( %$opts ) ) {
+			$self->{__option}->{ lc( $k ) } = $v || '';
+		}
+	}
+	$self->_parse_options;
+
+	my @file = @_;
+	foreach my $f (@file) {
+		$self->_rewrite_file( $f );
+	}
+
+	return;
+}
+
+sub _parse_options
+{
+	my $self = shift;
+	my $cwd = Cwd::getcwd();
+	foreach my $t ( qw(from to) ) {
+        $self->{__option}->{$t} = $cwd unless $self->{__option}->{$t};
+		my $d = $self->{__option}->{$t};
+		die "Couldn't read directory '$d'" unless -d $d && -r _;
+	}
+}
+
+sub _rewrite_file
+{
+	my ($self, $file) = @_;
+	my $source = File::Spec->catfile( $self->{__option}{from}, $file );
+	$source .= $self->{__option}{sufix} if $self->{__option}{sufix};
+	unless( -f $source && -r _ ) {
+		print STDERR "Couldn't find file '$source'\n";
+		return;
+	}
+	my $dest = File::Spec->catfile( $self->{__option}{to}, $file );
+	return $self->__rewrite_file( $source, $dest );
+}
+
+sub __rewrite_file
+{
+	my ($self, $source, $dest) = @_;
+
+	my $mode = (stat($source))[2];
+
+	open my $sfh, "<$source" or die "Couldn't open '$source' for read";
+	print "Open input '$source' file for substitution\n";
+
+	my ($tmpfh, $tmpfname) = File::Temp::tempfile('mi-subst-XXXX', UNLINK => 1);
+	$self->__process_streams( $sfh, $tmpfh, ($source eq $dest)? 1: 0 );
+	close $sfh;
+
+	seek $tmpfh, 0, 0 or die "Couldn't seek in tmp file";
+
+	open my $dfh, ">$dest" or die "Couldn't open '$dest' for write";
+	print "Open output '$dest' file for substitution\n";
+
+	while( <$tmpfh> ) {
+		print $dfh $_;
+	}
+	close $dfh;
+	chmod $mode, $dest or "Couldn't change mode on '$dest'";
+}
+
+sub __process_streams
+{
+	my ($self, $in, $out, $replace) = @_;
+	
+	my @queue = ();
+	my $subst = $self->{'__subst'};
+	my $re_subst = join('|', map {"\Q$_"} keys %{ $subst } );
+
+	while( my $str = <$in> ) {
+		if( $str =~ /^###\s*(before|replace|after)\:\s?(.*)$/s ) {
+			my ($action, $nstr) = ($1,$2);
+			$nstr =~ s/\@($re_subst)\@/$subst->{$1}/ge;
+
+			die "Replace action is bad idea for situations when dest is equal to source"
+                if $replace && $action eq 'replace';
+			if( $action eq 'before' ) {
+				die "no line before 'before' action" unless @queue;
+				# overwrite prev line;
+				pop @queue;
+				push @queue, $nstr;
+				push @queue, $str;
+			} elsif( $action eq 'replace' ) {
+				push @queue, $nstr;
+			} elsif( $action eq 'after' ) {
+				push @queue, $str;
+				push @queue, $nstr;
+				# skip one line;
+				<$in>;
+			}
+		} else {
+			push @queue, $str;
+		}
+		while( @queue > 3 ) {
+			print $out shift(@queue);
+		}
+	}
+	while( scalar @queue ) {
+		print $out shift(@queue);
+	}
+}
+
+1;
+
diff --git a/xt/basic.t b/xt/basic.t
index 446f48b..14b0403 100644
--- a/xt/basic.t
+++ b/xt/basic.t
@@ -2,7 +2,9 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 24, testing => 'RT::Extension::OneTimeTo';
+use lib 'xt/lib';
+
+use RT::Extension::OneTimeTo::Test tests => undef;
 
 my ($baseurl, $m) = RT::Test->started_ok;
 ok $m->login, 'logged in';
@@ -54,3 +56,4 @@ like( $mail, qr/this is main reply content/, 'email contains main reply content'
 like( $mail, qr/Cc:.*rt-test\@example.com/i, 'email contains Ccs');
 like( $mail, qr/To:.*rt-to-test\@example.com/i, 'email contains Tos');
 
+done_testing;
diff --git a/xt/empty-update.t b/xt/empty-update.t
index 712e61d..be3b694 100644
--- a/xt/empty-update.t
+++ b/xt/empty-update.t
@@ -2,7 +2,9 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 7, testing => 'RT::Extension::OneTimeTo';
+use lib 'xt/lib';
+
+use RT::Extension::OneTimeTo::Test tests => undef;
 
 my $ticket = RT::Ticket->new(RT->SystemUser);
 my ($ok, $txn, $msg) = $ticket->Create( Subject => 'testing', Queue => 'General' );
@@ -14,3 +16,4 @@ ok $ticket->id, "created ticket";
 ($ok, $msg, $txn) = $ticket->_RecordNote( Content => '' );
 ok !$ok, "can't record note without content or mimeobj ($msg)";
 
+done_testing;
diff --git a/xt/lib/RT/Extension/OneTimeTo/Test.pm.in b/xt/lib/RT/Extension/OneTimeTo/Test.pm.in
new file mode 100644
index 0000000..5724778
--- /dev/null
+++ b/xt/lib/RT/Extension/OneTimeTo/Test.pm.in
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+### after: use lib qw(@RT_LIB_PATH@);
+use lib qw(/opt/rt4/local/lib /opt/rt4/lib);
+
+package RT::Extension::OneTimeTo::Test;
+
+use base 'RT::Test';
+
+sub import {
+    my $class = shift;
+    my %args  = @_;
+
+    $class->SUPER::import( testing => 'RT::Extension::OneTimeTo', %args );
+    $class->export_to_level(1);
+
+    require RT::Extension::OneTimeTo;
+}
+
+1;

commit c7d52c7a6db32d292d8bafe319d26961bb4f130b
Author: Alex Vandiver <alex at chmrr.net>
Date:   Wed Jan 3 01:07:45 2018 -0800

    Version 1.03 releng

diff --git a/Changes b/Changes
index 3e933c8..56306c5 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+1.03 2018-01-03
+ - Fix tests to be author tests, and work without RT in @INC
+
 1.02 2017-02-20
  - Drop support for RT 4.0
  - Fix display of RT-Send-To header on RT 4.2 and above
diff --git a/META.yml b/META.yml
index 4ee38e9..e165c24 100644
--- a/META.yml
+++ b/META.yml
@@ -8,7 +8,7 @@ configure_requires:
   ExtUtils::MakeMaker: 6.59
 distribution_type: module
 dynamic_config: 1
-generated_by: 'Module::Install version 1.17'
+generated_by: 'Module::Install version 1.19'
 license: gpl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -26,7 +26,7 @@ requires:
 resources:
   license: http://opensource.org/licenses/gpl-license.php
   repository: https://github.com/bestpractical/rt-extension-onetimeto
-version: '1.02'
+version: '1.03'
 x_module_install_rtx_version: '0.39'
 x_requires_rt: 4.2.0
 x_rt_too_new: 4.6.0
diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm
index dbe10ca..7ba98c2 100644
--- a/inc/Module/Install.pm
+++ b/inc/Module/Install.pm
@@ -31,7 +31,7 @@ BEGIN {
 	# This is not enforced yet, but will be some time in the next few
 	# releases once we can make sure it won't clash with custom
 	# Module::Install extensions.
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 
 	# Storage for the pseudo-singleton
 	$MAIN    = undef;
diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm
index 3d89918..9fa42c2 100644
--- a/inc/Module/Install/Base.pm
+++ b/inc/Module/Install/Base.pm
@@ -4,7 +4,7 @@ package Module::Install::Base;
 use strict 'vars';
 use vars qw{$VERSION};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 }
 
 # Suspend handler for "redefined" warnings
diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm
index fc699b3..d65c753 100644
--- a/inc/Module/Install/Can.pm
+++ b/inc/Module/Install/Can.pm
@@ -8,7 +8,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm
index 3ee0aa1..3072b08 100644
--- a/inc/Module/Install/Fetch.pm
+++ b/inc/Module/Install/Fetch.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Include.pm b/inc/Module/Install/Include.pm
index e8a73b8..13fdcd0 100644
--- a/inc/Module/Install/Include.pm
+++ b/inc/Module/Install/Include.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm
index bc81e06..13a4464 100644
--- a/inc/Module/Install/Makefile.pm
+++ b/inc/Module/Install/Makefile.pm
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm
index 29934cf..11bf971 100644
--- a/inc/Module/Install/Metadata.pm
+++ b/inc/Module/Install/Metadata.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm
index dba25f9..f7aa615 100644
--- a/inc/Module/Install/Win32.pm
+++ b/inc/Module/Install/Win32.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm
index d553bd7..2db861a 100644
--- a/inc/Module/Install/WriteAll.pm
+++ b/inc/Module/Install/WriteAll.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }
diff --git a/lib/RT/Extension/OneTimeTo.pm b/lib/RT/Extension/OneTimeTo.pm
index 6546e11..c927cf8 100644
--- a/lib/RT/Extension/OneTimeTo.pm
+++ b/lib/RT/Extension/OneTimeTo.pm
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 no warnings 'redefine';
 
-our $VERSION = '1.02';
+our $VERSION = '1.03';
 
 {
     # Includes RT-Send-To in the list of headers used to grab

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list