diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-06-19 19:56:57 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-06-22 22:41:14 +0200 |
commit | 18388fdbd6a991f0d3b0c3df220014d82e8e4ff4 (patch) | |
tree | 5ff5c8c3117c3798fd3aa6f485abb5de9280134d | |
parent | a14453b94fa229e50f3dc0e7cc4b9a763b933cb6 (diff) | |
download | perl-18388fdbd6a991f0d3b0c3df220014d82e8e4ff4.tar.gz |
use TestInit 'T' in porting{authors,cmp_version,manifest}.t to chdir '..'
These three tests run git commands from the top level of the build tree, so
need to chdir '..' if run from 't'. use TestInit 'T' to do this, as it simplify
adapting the tests to also work when the build tree is a symlink forest from
-Dmksymlinks. TestInit also sets $ENV{PERL5LIB}, avoiding the need to use -Ilib
on the command line of the programs they run.
t/porting/manifest.t now runs throughout at the top level, which simplifies it
slightly.
-rw-r--r-- | t/porting/authors.t | 10 | ||||
-rw-r--r-- | t/porting/cmp_version.t | 8 | ||||
-rw-r--r-- | t/porting/manifest.t | 20 |
3 files changed, 17 insertions, 21 deletions
diff --git a/t/porting/authors.t b/t/porting/authors.t index 28ca1cabff..5fb933f38e 100644 --- a/t/porting/authors.t +++ b/t/porting/authors.t @@ -1,13 +1,11 @@ #!./perl -w - # Test that there are no missing authors in AUTHORS + BEGIN { - chdir '..' unless -d 't'; - unshift @INC, 'lib'; + @INC = '..' if -f '../TestInit.pm'; } - +use TestInit 'T'; # T is chdir to the top level use strict; -use warnings; if (! -d '.git' ) { print "1..0 # SKIP: not being run from a git checkout\n"; @@ -15,6 +13,6 @@ if (! -d '.git' ) { } my $dotslash = $^O eq "MSWin32" ? ".\\" : "./"; -system("git log --pretty=fuller | ${dotslash}perl -Ilib Porting/checkAUTHORS.pl --tap -"); +system("git log --pretty=fuller | ${dotslash}perl Porting/checkAUTHORS.pl --tap -"); # EOF diff --git a/t/porting/cmp_version.t b/t/porting/cmp_version.t index 7384416658..81cbf2c704 100644 --- a/t/porting/cmp_version.t +++ b/t/porting/cmp_version.t @@ -5,10 +5,12 @@ # Adapted from Porting/cmpVERSION.pl by Abigail # Changes folded back into that by Nicholas +BEGIN { + @INC = '..' if -f '../TestInit.pm'; +} +use TestInit 'T'; # T is chdir to the top level use strict; -chdir '..' unless -d 't'; - if (! -d '.git' ) { print "1..0 # SKIP: not being run from a git checkout\n"; exit 0; @@ -16,4 +18,4 @@ if (! -d '.git' ) { my $dotslash = $^O eq "MSWin32" ? ".\\" : "./"; -system "${dotslash}perl -Ilib Porting/cmpVERSION.pl --exclude --tap"; +system "${dotslash}perl Porting/cmpVERSION.pl --exclude --tap"; diff --git a/t/porting/manifest.t b/t/porting/manifest.t index 48dd3aca41..5534aca184 100644 --- a/t/porting/manifest.t +++ b/t/porting/manifest.t @@ -3,17 +3,15 @@ # Test the well-formed-ness of the MANIFEST file. BEGIN { - chdir 't'; - @INC = '../lib'; + @INC = '..' if -f '../TestInit.pm'; } +use TestInit 'T'; # T is chdir to the top level -use strict; -use File::Spec; -require './test.pl'; +require 't/test.pl'; plan('no_plan'); -my $manifest = File::Spec->catfile(File::Spec->updir(), 'MANIFEST'); +my $manifest = 'MANIFEST'; open my $m, '<', $manifest or die "Can't open '$manifest': $!"; my @files; @@ -29,8 +27,7 @@ while (<$m>) { push @files, $file; isnt($file, undef, "Line $. doesn't start with a blank") or next; - # Remember, we're running from t/ - ok(-f "../$file", "File $file exists"); + ok(-f $file, "File $file exists"); if ($separator !~ tr/\t//c) { # It's all tabs next; @@ -48,17 +45,16 @@ close $m or die $!; # Test that MANIFEST is properly sorted SKIP: { - skip("'Porting/manisort' not found", 1) if (! -f '../Porting/manisort'); + skip("'Porting/manisort' not found", 1) if (! -f 'Porting/manisort'); - my $result = runperl('progfile' => '../Porting/manisort', - 'args' => [ '-c', '../MANIFEST' ], + my $result = runperl('progfile' => 'Porting/manisort', + 'args' => [ '-c', $manifest ], 'stderr' => 1); like($result, qr/is sorted properly/, 'MANIFEST sorted properly'); } SKIP: { - chdir ".."; skip("not under git control", 3) unless -d '.git'; chomp(my @repo= grep { !/\.gitignore$/ } `git ls-files`); skip("git ls-files didnt work",3) |