Skip to content

Commit 838e86e

Browse files
dschoGit for Windows Build Agent
authored andcommitted
tests: exercise the RUNTIME_PREFIX feature
Originally, we refrained from adding a regression test in 7b6c649 (system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set, 2008-08-10), and in 226c0dd (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 <[email protected]>
1 parent cb5ca64 commit 838e86e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,11 @@ ifdef GIT_INTEROP_MAKE_OPTS
27692769
endif
27702770
ifdef GIT_TEST_INDEX_VERSION
27712771
@echo GIT_TEST_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_INDEX_VERSION)))'\' >>$@+
2772+
endif
2773+
ifdef RUNTIME_PREFIX
2774+
@echo RUNTIME_PREFIX=\'true\' >>$@+
2775+
else
2776+
@echo RUNTIME_PREFIX=\'false\' >>$@+
27722777
endif
27732778
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
27742779

t/t0060-path-utils.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,23 @@ test_expect_success MINGW 'MSYSTEM/PATH is adjusted if necessary' '
534534
test_write_lines MSYSTEM=$MSYSTEM mingw64 usr >expect &&
535535
test_cmp expect actual
536536
'
537+
538+
test_lazy_prereq RUNTIME_PREFIX '
539+
test true = "$RUNTIME_PREFIX"
540+
'
541+
542+
test_lazy_prereq CAN_EXEC_IN_PWD '
543+
cp "$GIT_EXEC_PATH"/git$X ./ &&
544+
./git rev-parse
545+
'
546+
547+
test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
548+
mkdir -p pretend/git pretend/libexec/git-core &&
549+
echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
550+
cp "$GIT_EXEC_PATH"/git$X pretend/git/ &&
551+
GIT_EXEC_PATH= ./pretend/git/git here >actual &&
552+
echo HERE >expect &&
553+
test_cmp expect actual
537554
'
538555

539556
test_done

0 commit comments

Comments
 (0)