]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
test_common: disable fsync in git(1) commands
authorEric Wong <e@80x24.org>
Fri, 15 Nov 2024 02:59:28 +0000 (02:59 +0000)
committerEric Wong <e@80x24.org>
Fri, 15 Nov 2024 20:27:42 +0000 (20:27 +0000)
As with git itself, fsync(2) results in needless overhead and
storage wear in test cases where data integrity is not an issue.
I normally point TMPDIR to tmpfs when running tests, but this
still affects initial setup of data for stuff in t/data-gen as
well as improving life for users with too little RAM for a tmpfs
TMPDIR.

lib/PublicInbox/TestCommon.pm

index 6c3677d2d99ecf494dfa0ec2670915a1dbe96dc4..b863ad6b7998f73b3ecb061b3adf187c2441433b 100644 (file)
@@ -18,6 +18,7 @@ our $tail_cmd = $ENV{TAIL};
 our ($lei_opt, $lei_out, $lei_err);
 use autodie qw(chdir close fcntl mkdir open opendir seek unlink);
 $ENV{XDG_CACHE_HOME} //= "$ENV{HOME}/.cache"; # reuse C++ xap_helper builds
+$ENV{GIT_TEST_FSYNC} = 0; # hopefully reduce wear
 
 $_ = File::Spec->rel2abs($_) for (grep(!m!^/!, @INC));
 our $CURRENT_DAEMON;
@@ -87,6 +88,7 @@ sub tmpdir (;$) {
        my ($base) = @_;
        require File::Temp;
        ($base) = ($0 =~ m!\b([^/]+)\.[^\.]+\z!) unless defined $base;
+       ($base) = ($0 =~ m!\b([^/]+)\z!) unless defined $base;
        my $tmpdir = File::Temp->newdir("pi-$base-$$-XXXX", TMPDIR => 1);
        wantarray ? ($tmpdir->dirname, $tmpdir) : $tmpdir;
 }