find_git_or_skip() will now follow symlinks and chdir to the real source tree.
authorNicholas Clark <nick@ccl4.org>
Sun, 19 Jun 2011 19:44:37 +0000 (21:44 +0200)
committerNicholas Clark <nick@ccl4.org>
Wed, 22 Jun 2011 20:41:18 +0000 (22:41 +0200)
porting{authors,cmp_version,manifest}.t now use TestInit qw(T A) to set @INC
and $^X to absolute paths, in case find_git_or_skip() changes directory.
As $^X is now absolute, there's no need to choose between '/' and '\\' based
on $^O.

t/porting/authors.t
t/porting/cmp_version.t
t/porting/manifest.t
t/test.pl

index 8777986..f67e930 100644 (file)
@@ -4,13 +4,12 @@
 BEGIN {
     @INC = '..' if -f '../TestInit.pm';
 }
-use TestInit 'T'; # T is chdir to the top level
+use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
 use strict;
 
 require 't/test.pl';
 find_git_or_skip('all');
 
-my $dotslash = $^O eq "MSWin32" ? ".\\" : "./";
-system("git log --pretty=fuller | ${dotslash}perl Porting/checkAUTHORS.pl --tap -");
+system("git log --pretty=fuller | $^X Porting/checkAUTHORS.pl --tap -");
 
 # EOF
index 2e3f15d..6204c57 100644 (file)
@@ -8,12 +8,10 @@
 BEGIN {
     @INC = '..' if -f '../TestInit.pm';
 }
-use TestInit 'T'; # T is chdir to the top level
+use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
 use strict;
 
 require 't/test.pl';
 find_git_or_skip('all');
 
-my $dotslash = $^O eq "MSWin32" ? ".\\" : "./";
-
-system "${dotslash}perl Porting/cmpVERSION.pl --exclude --tap";
+system "$^X Porting/cmpVERSION.pl --exclude --tap";
index caad265..292631e 100644 (file)
@@ -5,7 +5,7 @@
 BEGIN {
     @INC = '..' if -f '../TestInit.pm';
 }
-use TestInit 'T'; # T is chdir to the top level
+use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
 
 require 't/test.pl';
 
index c11d0b8..5a43da3 100644 (file)
--- a/t/test.pl
+++ b/t/test.pl
@@ -154,6 +154,18 @@ sub skip_all_without_config {
 
 sub find_git_or_skip {
     return if -d '.git';
+    if (-l 'MANIFEST' && -l 'AUTHORS') {
+       my $where = readlink 'MANIFEST';
+       die "Can't readling MANIFEST: $!" unless defined $where;
+       die "Confusing symlink target for MANIFEST, '$where'"
+           unless $where =~ s!/MANIFEST\z!!;
+       if (-d "$where/.git") {
+           # Looks like we are in a symlink tree
+           chdir $where or die "Can't chdir '$where': $!";
+           note("Found source tree at $where");
+           return;
+       }
+    }
     my $reason = 'not being run from a git checkout';
     skip_all($reason) if $_[0] && $_[0] eq 'all';
     skip($reason, @_);