THRIFT-4691: ensure CPAN module runs unit tests
diff --git a/configure.ac b/configure.ac
index d229734..c5683ec 100755
--- a/configure.ac
+++ b/configure.ac
@@ -821,7 +821,7 @@
   lib/nodejs/Makefile
   lib/nodets/Makefile
   lib/perl/Makefile
-  lib/perl/test/Makefile
+  lib/perl/t/Makefile
   lib/php/Makefile
   lib/php/test/Makefile
   lib/dart/Makefile
diff --git a/lib/perl/MANIFEST.SKIP b/lib/perl/MANIFEST.SKIP
index 7963b42..9b04450 100644
--- a/lib/perl/MANIFEST.SKIP
+++ b/lib/perl/MANIFEST.SKIP
@@ -8,6 +8,7 @@
 Makefile.am
 Makefile.in
 pm_to_blib
-test/Makefile.am
-test/Makefile.in
+t/Makefile
+t/Makefile.am
+t/Makefile.in
 tools/FixupDist.pl
diff --git a/lib/perl/Makefile.PL b/lib/perl/Makefile.PL
index bdeaad2..5e60ab4 100644
--- a/lib/perl/Makefile.PL
+++ b/lib/perl/Makefile.PL
@@ -33,4 +33,17 @@
                    'Bit::Vector'     => 0,
                    'Class::Accessor' => 0
                },
+#              SIGN => 1,
                VERSION_FROM => 'lib/Thrift.pm' );
+
+# THRIFT-4691
+package MY; # so that "SUPER" works right
+sub test {
+    # Adds gen-perl and gen-perl2 to the test execution as include paths
+    # Could not find anything in MakeMaker that would do this...
+    my @result;
+    for (@result = shift->SUPER::test(@_)) {
+        s/\$\(TEST_FILES\)/-Igen-perl -Igen-perl2 \$(TEST_FILES)/ig;
+    }
+    @result;
+}
diff --git a/lib/perl/Makefile.am b/lib/perl/Makefile.am
index fa0f16b..abae1e7 100644
--- a/lib/perl/Makefile.am
+++ b/lib/perl/Makefile.am
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-SUBDIRS = test
+SUBDIRS = t
 
 Makefile-perl.mk : Makefile.PL
 	$(PERL) Makefile.PL MAKEFILE=Makefile-perl.mk INSTALLDIRS=$(INSTALLDIRS) INSTALL_BASE=$(PERL_PREFIX)
@@ -95,7 +95,7 @@
 
 check-local: $(PERL_GEN)
 	$(PERL) -Iblib/lib -I@abs_srcdir@ -I@builddir@/gen-perl2 -I@builddir@/gen-perl \
-		@abs_srcdir@/test.pl @abs_srcdir@/test/*.t
+		@abs_srcdir@/test.pl @abs_srcdir@/t/*.t
 
 $(THRIFTTEST_GEN): $(THRIFT_IF) $(THRIFT)
 	$(THRIFT) --gen perl $<
diff --git a/lib/perl/build-cpan-dist.sh b/lib/perl/build-cpan-dist.sh
index ae22e7e..ac0ff0b 100755
--- a/lib/perl/build-cpan-dist.sh
+++ b/lib/perl/build-cpan-dist.sh
@@ -12,9 +12,10 @@
 
 # setup cpan without a prompt
 echo | cpan
-cpan install HTTP::Date
+cpan install HTTP::Date Log::Log4perl
 cpan install CPAN
 cpan install CPAN::Meta ExtUtils::MakeMaker JSON::PP
+# cpan install Module::Signature
 
 perl Makefile.PL
 rm MYMETA.yml
@@ -47,6 +48,8 @@
 fi
 cd $DISTDIR
 cp -p ../Makefile.PL .
+cp -pr ../gen-perl .
+cp -pr ../gen-perl2 .
 perl ../tools/FixupDist.pl
 cd ..
 tar cvzf $DISTFILE $DISTDIR
diff --git a/lib/perl/test/Makefile.am b/lib/perl/t/Makefile.am
similarity index 100%
rename from lib/perl/test/Makefile.am
rename to lib/perl/t/Makefile.am
diff --git a/lib/perl/test/memory_buffer.t b/lib/perl/t/memory_buffer.t
similarity index 100%
rename from lib/perl/test/memory_buffer.t
rename to lib/perl/t/memory_buffer.t
diff --git a/lib/perl/test/multiplex.t b/lib/perl/t/multiplex.t
similarity index 100%
rename from lib/perl/test/multiplex.t
rename to lib/perl/t/multiplex.t
diff --git a/lib/perl/test/processor.t b/lib/perl/t/processor.t
similarity index 100%
rename from lib/perl/test/processor.t
rename to lib/perl/t/processor.t