tests: exercise the RUNTIME_PREFIX feature
Originally, we refrained from adding a regression test in 7b6c6496374 (system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set, 2008-08-10), and in 226c0ddd0d6 (exec_cmd: RUNTIME_PREFIX on some POSIX systems, 2018-04-10). The reason was that it was deemed too tricky to test. Turns out that it is not tricky to test at all: we simply create a pseudo-root, copy the `git` executable into the `git/` subdirectory of that pseudo-root, then copy a script into the `libexec/git-core/` directory and expect that to be picked up. As long as the trash directory is in a location where binaries can be executed, this works. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jul 24, 2021 at 22:06 UTC
b7d11a0f5d2db1eff623150cdc2a2ddccd6845b3
2 files changed
+23
Makefile
+5
@@ -2826,6 +2826,11 @@ ifdef GIT_TEST_INDEX_VERSION
2826
endif
2827
ifdef GIT_TEST_PERL_FATAL_WARNINGS
2828
@echo GIT_TEST_PERL_FATAL_WARNINGS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_PERL_FATAL_WARNINGS)))'\' >>$@+
2829
+endif
2830
+ifdef RUNTIME_PREFIX
2831
+ @echo RUNTIME_PREFIX=\'true\' >>$@+
2832
+else
2833
+ @echo RUNTIME_PREFIX=\'false\' >>$@+
2834
endif
2835
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
2836
t/t0060-path-utils.sh
+18
@@ -525,4 +525,22 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
525
"PRN./abc"
526
'
527
528
+test_lazy_prereq RUNTIME_PREFIX '
529
+ test true = "$RUNTIME_PREFIX"
530
+'
531
+
532
+test_lazy_prereq CAN_EXEC_IN_PWD '
533
+ cp "$GIT_EXEC_PATH"/git$X ./ &&
534
+ ./git rev-parse
535
+'
536
+
537
+test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
538
+ mkdir -p pretend/bin pretend/libexec/git-core &&
539
+ echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
540
+ cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
541
+ GIT_EXEC_PATH= ./pretend/bin/git here >actual &&
542
+ echo HERE >expect &&
543
+ test_cmp expect actual
544
+'
545
+
546
test_done