git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <rsbecker@nexbridge.com>
To: <git@vger.kernel.org>
Subject: [Bug] Temp file use in t0018.6
Date: Thu, 1 Aug 2024 14:15:07 -0400	[thread overview]
Message-ID: <02d401dae43e$c076b000$41641000$@nexbridge.com> (raw)

In the 2.46.0 test suite on NonStop I'm getting the following surprise
error:

expecting success of 0018.6 'advice should be printed when GIT_ADVICE is set
to true':
        q_to_tab >expect <<-\EOF &&
        On branch trunk

        No commits yet

        Untracked files:
          (use "git add <file>..." to include in what will be committed)
        QREADME

        nothing added to commit but untracked files present (use "git add"
to track)
        EOF

        test_when_finished "rm -fr advice-test" &&
        git init advice-test &&
        (
                cd advice-test &&
                >README &&
                GIT_ADVICE=true git status
        ) >actual &&
        cat actual > /tmp/actual &&
        test_cmp expect actual

Initialized empty Git repository in /home/randall/git-clar/t/trash
directory.t0018-advice/advice-test/.git/
./test-lib.sh: line 1071: /tmp/actual: Permission denied
not ok 6 - advice should be printed when GIT_ADVICE is set to true

This is the first I'm seeing a failure I'm seeing of this kind. We should be
using randomized temp
locations, not fixed. What is going on is that our main CI system runs under
one user id while I was
running another test under my own user. Our /tmp is configured so that users
who create files have
exclusive access to those files, regardless of security so /tmp/actual in
this case can only be used in
one run by one user. What we should be doing is probably generating
/tmp/actual.XXXXXXX
(randomized) or using actual in the trash directory as normal. In any event,
t0018 should be
cleaning up and removing /tmp/actual when done. I would suggest doing
something like this as
a start:

diff --git a/t/t0018-advice.sh b/t/t0018-advice.sh
index 29306b367c..1676a1a31d 100755
--- a/t/t0018-advice.sh
+++ b/t/t0018-advice.sh
@@ -97,7 +97,8 @@ test_expect_success 'advice should be printed when
GIT_ADVICE is set to true' '
                GIT_ADVICE=true git status
        ) >actual &&
        cat actual > /tmp/actual &&
-       test_cmp expect actual
+       test_cmp expect actual &&
+       rm /tmp/actual
 '

And then, as a real fix:

diff --git a/t/t0018-advice.sh b/t/t0018-advice.sh
index 29306b367c..deba8a1d91 100755
--- a/t/t0018-advice.sh
+++ b/t/t0018-advice.sh
@@ -96,8 +96,10 @@ test_expect_success 'advice should be printed when
GIT_ADVICE is set to true' '
                >README &&
                GIT_ADVICE=true git status
        ) >actual &&
-       cat actual > /tmp/actual &&
-       test_cmp expect actual
+       ACTUAL=/tmp/actual.$RANDOM &&
+       cat actual > $ACTUAL &&
+       test_cmp expect $ACTUAL &&
+       rm $ACTUAL
 '

Regards,
Randall




             reply	other threads:[~2024-08-01 18:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01 18:15 rsbecker [this message]
2024-08-01 18:34 ` [Bug] Temp file use in t0018.6 Junio C Hamano
2024-08-01 18:51   ` [PATCH] t0018: remove leftover debugging cruft Junio C Hamano
2024-08-01 18:53     ` rsbecker
2024-08-01 18:51   ` [Bug] Temp file use in t0018.6 rsbecker
2024-08-02  3:39     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='02d401dae43e$c076b000$41641000$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).