Skip to content

Commit fc4c701

Browse files
committed
Merge branch 'fix-CTest-failures'
This topic branch fixes a couple of problems when running Git for Windows' tests via CTest (e.g. inside Visual Studio). Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 79972f5 + c7fc5a4 commit fc4c701

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/fuzz_corpora
33
/fuzz-pack-headers
44
/fuzz-pack-idx
5+
/GIT-BUILD-DIR
56
/GIT-BUILD-OPTIONS
67
/GIT-CFLAGS
78
/GIT-LDFLAGS

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,6 +3037,7 @@ else
30373037
@echo RUNTIME_PREFIX=\'false\' >>$@+
30383038
endif
30393039
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
3040+
@if test -f GIT-BUILD-DIR; then rm GIT-BUILD-DIR; fi
30403041

30413042
### Detect Python interpreter path changes
30423043
ifndef NO_PYTHON

add-patch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ static int patch_update_file(struct add_p_state *s,
15471547
strbuf_remove(&s->answer, 0, 1);
15481548
strbuf_trim(&s->answer);
15491549
i = hunk_index - DISPLAY_HUNKS_LINES / 2;
1550-
if (i < file_diff->mode_change)
1550+
if (i < (int)file_diff->mode_change)
15511551
i = file_diff->mode_change;
15521552
while (s->answer.len == 0) {
15531553
i = display_hunks(s, file_diff, i);

contrib/buildsystems/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,18 +1102,14 @@ endif()
11021102
#Make the tests work when building out of the source tree
11031103
get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
11041104
if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
1105-
file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
1106-
string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
11071105
#Setting the build directory in test-lib.sh before running tests
11081106
file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
1109-
"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
1110-
"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
1111-
"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\"\" content \"\${content}\")\n"
1112-
"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
1107+
"file(WRITE ${CMAKE_SOURCE_DIR}/GIT-BUILD-DIR \"${CMAKE_BINARY_DIR}\")")
11131108
#misc copies
11141109
file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
11151110
file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
1116-
file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
1111+
file(GLOB mergetools "${CMAKE_SOURCE_DIR}/mergetools/*")
1112+
file(COPY ${mergetools} DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
11171113
file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
11181114
file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
11191115
endif()
@@ -1123,7 +1119,7 @@ file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
11231119
#test
11241120
foreach(tsh ${test_scipts})
11251121
add_test(NAME ${tsh}
1126-
COMMAND ${SH_EXE} ${tsh}
1122+
COMMAND ${SH_EXE} ${tsh} --no-bin-wrappers --no-chain-lint -vx
11271123
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
11281124
endforeach()
11291125

t/test-lib-functions.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ test_commit_bulk () {
492492
# of a file in the working directory and add it to the index.
493493

494494
test_chmod () {
495-
chmod "$@" &&
495+
if test_have_prereq !MINGW
496+
then
497+
chmod "$@"
498+
fi &&
496499
git update-index --add "--chmod=$@"
497500
}
498501

@@ -548,7 +551,10 @@ write_script () {
548551
echo "#!${2-"$SHELL_PATH"}" &&
549552
cat
550553
} >"$1" &&
551-
chmod +x "$1"
554+
if test_have_prereq !MINGW
555+
then
556+
chmod +x "$1"
557+
fi
552558
}
553559

554560
# Usage: test_hook [options] <hook-name> <<-\EOF

t/test-lib.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ then
5151
TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
5252
fi
5353
GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
54-
if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
54+
if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR"
55+
then
56+
GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1
57+
# On Windows, we must convert Windows paths lest they contain a colon
58+
case "$(uname -s)" in
59+
*MINGW*)
60+
GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")"
61+
;;
62+
esac
63+
elif test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
5564
then
5665
echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2
5766
exit 1

0 commit comments

Comments
 (0)