From c45a5498bc035c94420b87a7ee4cf696403bc429 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Jun 2025 10:14:47 +0000 Subject: [PATCH] test_common: symlink xap_helper instead of excessive copying Copying the entire directory is racy in the face of parallel tests and caused an occasional test failure due to attempts (and failures) in copying short-lived temporary files. A symlink for just the executable avoids attempted copies temporary files is less expensive for the intended file, as well. --- lib/PublicInbox/TestCommon.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index e0274610d..fe81b3059 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -16,7 +16,7 @@ our @EXPORT; my $lei_loud = $ENV{TEST_LEI_ERR_LOUD}; our $tail_cmd = $ENV{TAIL}; our ($lei_opt, $lei_out, $lei_err, $find_xh_pid); -use autodie qw(chdir close fcntl mkdir open opendir seek unlink); +use autodie qw(chdir close fcntl mkdir open opendir seek symlink unlink); $ENV{XDG_CACHE_HOME} //= "$ENV{HOME}/.cache"; # reuse C++ xap_helper builds $ENV{GIT_TEST_FSYNC} = 0; # hopefully reduce wear @@ -783,12 +783,12 @@ SKIP: { my $home = "$tmpdir/lei-daemon"; mkdir($home, 0700); local $ENV{HOME} = $home; - if ($xh_cmd && $xh_cmd->[0] =~ m!\A(.+)/+[^/]+\z!) { - # avoid repeated rebuilds by copying - my $src = $1; + if ($xh_cmd && $xh_cmd->[0] =~ m!\A.+/+([^/]+)\z!) { + # avoid repeated rebuilds by symlinking + my ($src, $bn) = ($xh_cmd->[0], $1); my $dst = "$home/.cache/public-inbox/jaot"; File::Path::make_path($dst); - xsys_e([qw(/bin/cp -Rp), $src, $dst ]); + symlink $src, "$dst/$bn"; } my $persist; if ($persist_xrd && !$test_opt->{daemon_only}) { -- 2.39.5