From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 08C131F452 for ; Wed, 6 Dec 2023 21:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1701897146; bh=sMJ0Y4mSyGM5rarHiBNTwfop4Unj3IGDYecqEJ+egUY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HU5K9U7woq79CKDWu2DVBnrlUFc0KY9IiOiXYcllxHV1g3LxkTb+tVehQQA/L8JaT xMLs+Ewf3ncbLEDJNPbYhvaYmxgVyOiET8ALhxBr5eXMJbC1L1OpRWCdtSSRz2xQAX qFPiXuNLSVijrLyQufag9/13+4W3gwt2OeKLQ5s4= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] t/cindex: fix test when worktree PWD is a symlink Date: Wed, 6 Dec 2023 21:12:24 +0000 Message-Id: <20231206211225.2952183-2-e@80x24.org> In-Reply-To: <20231206211225.2952183-1-e@80x24.org> References: <20231206211225.2952183-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Our code aims to respect $ENV{PWD} (and therefore symlinks) as much as possible to ensure portability across devices when repos and indices are on portable or shared storage. Thus we can't rely on Cwd::abs_path and ought to favor File::Spec->rel2abs whenever absolute paths are required. I noticed this when working on a VM where my worktree is a symlink to a more reliable device. --- t/cindex.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/cindex.t b/t/cindex.t index 716e5984..15c860e1 100644 --- a/t/cindex.t +++ b/t/cindex.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ use v5.12; use PublicInbox::TestCommon; -use Cwd qw(getcwd abs_path); +use Cwd qw(getcwd); use List::Util qw(sum); use autodie qw(close mkdir open rename); require_mods(qw(json Xapian +SCM_RIGHTS)); @@ -67,6 +67,7 @@ git gc -q EOM }; # /create_coderepo +$zp = File::Spec->rel2abs($zp); ok(run_script([qw(-cindex --dangerous -q -d), "$tmp/ext", '-g', $zp, '-g', "$tmp/wt0" ]), 'cindex external'); @@ -125,7 +126,7 @@ use_ok 'PublicInbox::CodeSearch'; my @xh_args; my $exp = [ 'initial with NUL character', 'remove NUL character' ]; -my $zp_git = abs_path("$zp/.git"); +my $zp_git = "$zp/.git"; if ('multi-repo search') { my $csrch = PublicInbox::CodeSearch->new("$tmp/ext"); my $mset = $csrch->mset('NUL');