Skip to content

Commit

Permalink
tests: exercise the RUNTIME_PREFIX feature
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Feb 11, 2020
1 parent 08c2af3 commit 703013f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,11 @@ ifdef GIT_INTEROP_MAKE_OPTS
endif
ifdef GIT_TEST_INDEX_VERSION
@echo GIT_TEST_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_INDEX_VERSION)))'\' >>$@+
endif
ifdef RUNTIME_PREFIX
@echo RUNTIME_PREFIX=\'true\' >>$@+
else
@echo RUNTIME_PREFIX=\'false\' >>$@+
endif
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi

Expand Down
17 changes: 17 additions & 0 deletions t/t0060-path-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,23 @@ test_expect_success MINGW 'MSYSTEM/PATH is adjusted if necessary' '
test_write_lines MSYSTEM=$MSYSTEM mingw64 usr >expect &&
test_cmp expect actual
'

test_lazy_prereq RUNTIME_PREFIX '
test true = "$RUNTIME_PREFIX"
'

test_lazy_prereq CAN_EXEC_IN_PWD '
cp "$GIT_EXEC_PATH"/git$X ./ &&
./git rev-parse
'

test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
mkdir -p pretend/git pretend/libexec/git-core &&
echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
cp "$GIT_EXEC_PATH"/git$X pretend/git/ &&
GIT_EXEC_PATH= ./pretend/git/git here >actual &&
echo HERE >expect &&
test_cmp expect actual
'

test_done

0 comments on commit 703013f

Please sign in to comment.