diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2018-11-14 08:32:11 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-16 14:18:00 +0900 |
commit | 8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f (patch) | |
tree | fc29a6ad46fe2531361ac2ffa055dfa13d249bde /t/test-lib-functions.sh | |
parent | ed306e4e0fbb621001f008e6d50718898be4fc09 (diff) | |
download | git-8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f.tar.gz |
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-functions.sh')
-rw-r--r-- | t/test-lib-functions.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 3472716651..274cbc2d6e 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -923,7 +923,7 @@ test_create_repo () { mkdir -p "$repo" ( cd "$repo" || error "Cannot setup test environment" - "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git" init \ + "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" init \ "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" mv .git/hooks .git/hooks-disabled |