diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2018-11-14 16:32:11 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-16 05:18:00 (GMT) |
commit | 8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f (patch) | |
tree | fc29a6ad46fe2531361ac2ffa055dfa13d249bde /t/test-lib.sh | |
parent | ed306e4e0fbb621001f008e6d50718898be4fc09 (diff) | |
download | git-8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f.zip git-8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f.tar.gz git-8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f.tar.bz2 |
tests: explicitly use `git.exe` on Windows
On Windows, when we refer to `/an/absolute/path/to/git`, it magically
resolves `git.exe` at that location. Except if something of the name
`git` exists next to that `git.exe`. So if we call `$BUILD_DIR/git`, it
will find `$BUILD_DIR/git.exe` *only* if there is not, say, a directory
called `$BUILD_DIR/git`.
Such a directory, however, exists in Git for Windows when building with
Visual Studio (our Visual Studio project generator defaults to putting
the build files into a directory whose name is the base name of the
corresponding `.exe`).
In the bin-wrappers/* scripts, we already take pains to use `git.exe`
rather than `git`, as this could pick up the wrong thing on Windows
(i.e. if there exists a `git` file or directory in the build directory).
Now we do the same in the tests' start-up code.
This also helps when testing an installed Git, as there might be even
more likely some stray file or directory in the way.
Note: the only way we can record whether the `.exe` suffix is by writing
it to the `GIT-BUILD-OPTIONS` file and sourcing it at the beginning of
`t/test-lib.sh`. This is not a requirement introduced by this patch, but
we move the call to be able to use the `$X` variable that holds the file
extension, if any.
Note also: the many, many calls to `git this` and `git that` are
unaffected, as the regular PATH search will find the `.exe` files on
Windows (and not be confused by a directory of the name `git` that is
in one of the directories listed in the `PATH` variable), while
`/path/to/git` would not, per se, know that it is looking for an
executable and happily prefer such a directory.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 3d3a65e..e12addc 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -49,9 +49,17 @@ export ASAN_OPTIONS : ${LSAN_OPTIONS=abort_on_error=1} export LSAN_OPTIONS +if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS +then + echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).' + exit 1 +fi +. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS +export PERL_PATH SHELL_PATH + ################################################################ # It appears that people try to run tests without building... -"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git" >/dev/null +"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null if test $? != 1 then if test -n "$GIT_TEST_INSTALLED" @@ -63,9 +71,6 @@ then exit 1 fi -. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS -export PERL_PATH SHELL_PATH - # if --tee was passed, write the output not only to the terminal, but # additionally to the file test-results/$BASENAME.out, too. case "$GIT_TEST_TEE_STARTED, $* " in |