git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test-lib: make sure TEST_DIRECTORY has no trailing slash
@ 2023-10-03  8:23 Štěpán Němec
  2023-10-03 21:21 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Štěpán Němec @ 2023-10-03  8:23 UTC (permalink / raw)
  To: git

Turns out having `pwd` (which TEST_DIRECTORY defaults to) print $PWD
with a trailing slash isn't very difficult, in my case it went something
like

  ; tmux new-window -c ~/src/git/t/
  [in the new window]
  ; sh ./t0000-basic.sh
  PANIC: Running in a /home/stepnem/src/git/t/ that doesn't end in '/t'?
  ; pwd
  /home/stepnem/src/git/t/

(tmux(1) apparently sets PWD in the environment in addition to calling
chdir(2), which seems enough to make at least some shells preserve the
trailing slash in `pwd` output.)

Strip the trailing slash, if present, to prevent bailing out with the
PANIC message in such cases.

Signed-off-by: Štěpán Němec <stepnem@smrk.net>
---
 t/test-lib.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 1656c9eed006..3b6f1a17e349 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -35,6 +35,7 @@ else
 	# needing to exist.
 	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
+TEST_DIRECTORY="${TEST_DIRECTORY%/}"
 if test -z "$TEST_OUTPUT_DIRECTORY"
 then
 	# Similarly, override this to store the test-results subdir

base-commit: d0e8084c65cbf949038ae4cc344ac2c2efd77415
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-04 18:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03  8:23 [PATCH] test-lib: make sure TEST_DIRECTORY has no trailing slash Štěpán Němec
2023-10-03 21:21 ` Junio C Hamano
2023-10-03 21:57   ` Junio C Hamano
2023-10-04  9:34     ` Štěpán Němec
2023-10-04 16:19       ` Junio C Hamano
2023-10-04 17:01         ` Štěpán Němec
2023-10-04 17:15           ` Junio C Hamano
2023-10-04 17:40             ` Štěpán Němec
2023-10-04 18:24               ` Junio C Hamano

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).