]> Sergey Matveev's repositories - public-inbox.git/commitdiff
tests: get rid of unnecessary Cwd module use
authorEric Wong <e@80x24.org>
Tue, 14 May 2019 03:32:03 +0000 (03:32 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 May 2019 04:00:10 +0000 (04:00 +0000)
We only need it for tests that chdir, and maybe for ENV{PATH}
portability (dash seems fine, not sure about others).

v2: revert change to solver_git.t for FreeBSD 11.2 and document

t/admin.t
t/cgi.t
t/git.t
t/httpd-corner.t
t/httpd-unix.t
t/httpd.t
t/mda.t
t/nntpd.t
t/solver_git.t
t/spamcheck_spamc.t

index cc1e65d12fc90f03a3775dc3c4c2189d97d0a529..b5a4383ec67d84b08c6e11c4e012bb5a65e7288e 100644 (file)
--- a/t/admin.t
+++ b/t/admin.t
@@ -4,7 +4,6 @@ use strict;
 use warnings;
 use Test::More;
 use File::Temp qw(tempdir);
-# use Cwd qw(getcwd);
 use_ok 'PublicInbox::Admin', qw(resolve_repo_dir);
 my $tmpdir = tempdir('pi-admin.XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/v1";
diff --git a/t/cgi.t b/t/cgi.t
index aedd79efbf3e089ac0780095ee72de9296515d92..b24bbc4ac5f244f0e66bea26f32c463d35ae2087 100644 (file)
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -7,7 +7,6 @@ use warnings;
 use Test::More;
 use Email::MIME;
 use File::Temp qw/tempdir/;
-use Cwd;
 eval { require IPC::Run };
 plan skip_all => "missing IPC::Run for t/cgi.t" if $@;
 
diff --git a/t/git.t b/t/git.t
index 5b612b8e42d9cab7792e84774579b55cbbd8615d..7edf82b44a6dd124cee85e89a1a5f219313a85dc 100644 (file)
--- a/t/git.t
+++ b/t/git.t
@@ -5,7 +5,6 @@ use warnings;
 use Test::More;
 use File::Temp qw/tempdir/;
 my $dir = tempdir('pi-git-XXXXXX', TMPDIR => 1, CLEANUP => 1);
-use Cwd qw/getcwd/;
 use PublicInbox::Spawn qw(popen_rd);
 
 eval { require IPC::Run } or plan skip_all => 'IPC::Run missing';
@@ -15,7 +14,7 @@ use_ok 'PublicInbox::Git';
        is(system(qw(git init -q --bare), $dir), 0, 'created git directory');
        my $cmd = [ 'git', "--git-dir=$dir", 'fast-import', '--quiet' ];
 
-       my $fi_data = getcwd().'/t/git.fast-import-data';
+       my $fi_data = './t/git.fast-import-data';
        ok(-r $fi_data, "fast-import data readable (or run test at top level)");
        IPC::Run::run($cmd, '<', $fi_data);
        is($?, 0, 'fast-import succeeded');
@@ -68,7 +67,7 @@ if (1) {
        my $cmd = [ 'git', "--git-dir=$dir", qw(hash-object -w --stdin) ];
 
        # need a big file, use the AGPL-3.0 :p
-       my $big_data = getcwd().'/COPYING';
+       my $big_data = './COPYING';
        ok(-r $big_data, 'COPYING readable');
        my $size = -s $big_data;
        ok($size > 8192, 'file is big enough');
index bfa39205ccd7dc40d67559397882230e40afc73a..7c21994356b3ad8ba4fd8e3995057725f4c2d4f8 100644 (file)
@@ -15,7 +15,6 @@ foreach my $mod (qw(Plack::Util Plack::Builder
 
 use Digest::SHA qw(sha1_hex);
 use File::Temp qw/tempdir/;
-use Cwd qw/getcwd/;
 use IO::Socket;
 use IO::Socket::UNIX;
 use Fcntl qw(:seek);
@@ -28,7 +27,7 @@ ok(defined mkfifo($fifo, 0777), 'created FIFO');
 my $err = "$tmpdir/stderr.log";
 my $out = "$tmpdir/stdout.log";
 my $httpd = 'blib/script/public-inbox-httpd';
-my $psgi = getcwd()."/t/httpd-corner.psgi";
+my $psgi = "./t/httpd-corner.psgi";
 my %opts = (
        LocalAddr => '127.0.0.1',
        ReuseAddr => 1,
index 2ef64dfcd0968921ef93f841ac646bb17a2fafae..758277c9d67977304663346fed62b3e1d5e984de 100644 (file)
@@ -12,11 +12,10 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) {
 
 use File::Temp qw/tempdir/;
 use IO::Socket::UNIX;
-use Cwd qw/getcwd/;
 my $tmpdir = tempdir('httpd-unix-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $unix = "$tmpdir/unix.sock";
 my $httpd = 'blib/script/public-inbox-httpd';
-my $psgi = getcwd() . '/t/httpd-corner.psgi';
+my $psgi = './t/httpd-corner.psgi';
 my $out = "$tmpdir/out.log";
 my $err = "$tmpdir/err.log";
 
index d55495ff6137e18c296c61b7a3f60e4a682759d7..c061031cc662f7b63d6d9c4fffb2caebf2fdc926 100644 (file)
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -9,7 +9,6 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) {
        plan skip_all => "$mod missing for httpd.t" if $@;
 }
 use File::Temp qw/tempdir/;
-use Cwd qw/getcwd/;
 use IO::Socket::INET;
 require './t/common.perl';
 
diff --git a/t/mda.t b/t/mda.t
index 5dbcec63fc100dfa5c60e84e0c82353a58c23d69..966600a899d56d792e24471145d2e62977a2d8b0 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use Email::MIME;
 use File::Temp qw/tempdir/;
-use Cwd;
+use Cwd qw(getcwd);
 use PublicInbox::MID qw(mid2path);
 eval { require IPC::Run };
 plan skip_all => "missing IPC::Run for t/mda.t" if $@;
index ec0a621c46f4e7724fcc51df46b0da0564ae9eab..b8a84a0c2c003b00ae681e8cd0bda94e8c57f517 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -9,7 +9,6 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
 }
 require PublicInbox::SearchIdx;
 require PublicInbox::Msgmap;
-use Cwd;
 use Email::Simple;
 use IO::Socket;
 use Socket qw(IPPROTO_TCP TCP_NODELAY);
index 6f0ce777477b65a3a2ccdf41e612dc69095324b2..0b7d7c49485088d123d9c0040a5db61531955268 100644 (file)
@@ -16,6 +16,8 @@ foreach my $mod (@mods) {
 }
 chomp(my $git_dir = `git rev-parse --git-dir 2>/dev/null`);
 plan skip_all => "$0 must be run from a git working tree" if $?;
+
+# needed for alternates, and --absolute-git-dir is only in git 2.13+
 $git_dir = abs_path($git_dir);
 
 use_ok "PublicInbox::$_" for (qw(Inbox V2Writable MIME Git SolverGit));
index 7016e8bfd3fc54e7b559d5c4e56e95f5a5d4bb6d..70de14b689d532acfba3e46f22b2544e568ebf52 100644 (file)
@@ -3,7 +3,6 @@
 use strict;
 use warnings;
 use Test::More;
-use Cwd;
 use Email::Simple;
 use IO::File;
 use File::Temp qw/tempdir/;