Skip to content

Commit 18da1d2

Browse files
authored
Fix CTest failures (git-for-windows#3977)
When building Git via Visual Studio and then running the tests via CTest (which is made very easy by Visual Studio), there are test failures. This PR intends to address those. This closes git-for-windows#3966
2 parents beeaffb + 474668c commit 18da1d2

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
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
@@ -3082,6 +3082,7 @@ else
30823082
@echo RUNTIME_PREFIX=\'false\' >>$@+
30833083
endif
30843084
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
3085+
@if test -f GIT-BUILD-DIR; then rm GIT-BUILD-DIR; fi
30853086

30863087
### Detect Python interpreter path changes
30873088
ifndef NO_PYTHON

contrib/buildsystems/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,18 +1105,14 @@ endif()
11051105
#Make the tests work when building out of the source tree
11061106
get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
11071107
if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
1108-
file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
1109-
string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
11101108
#Setting the build directory in test-lib.sh before running tests
11111109
file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
1112-
"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
1113-
"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
1114-
"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\"\" content \"\${content}\")\n"
1115-
"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
1110+
"file(WRITE ${CMAKE_SOURCE_DIR}/GIT-BUILD-DIR \"${CMAKE_BINARY_DIR}\")")
11161111
#misc copies
11171112
file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.pl DESTINATION ${CMAKE_BINARY_DIR}/t/)
11181113
file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
1119-
file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
1114+
file(GLOB mergetools "${CMAKE_SOURCE_DIR}/mergetools/*")
1115+
file(COPY ${mergetools} DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
11201116
file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
11211117
file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
11221118
endif()
@@ -1126,8 +1122,12 @@ file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
11261122
#test
11271123
foreach(tsh ${test_scipts})
11281124
add_test(NAME ${tsh}
1129-
COMMAND ${SH_EXE} ${tsh}
1125+
COMMAND ${SH_EXE} ${tsh} --no-bin-wrappers --no-chain-lint -vx
11301126
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
11311127
endforeach()
11321128

1129+
# This test script takes an extremely long time and is known to time out even
1130+
# on fast machines because it requires in excess of one hour to run
1131+
set_tests_properties("${CMAKE_SOURCE_DIR}/t/t7112-reset-submodule.sh" PROPERTIES TIMEOUT 4000)
1132+
11331133
endif()#BUILD_TESTING

t/t0060-path-utils.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,14 @@ test_expect_success MINGW 'MSYSTEM/PATH is adjusted if necessary' '
566566
pretend/mingw64/libexec/git-core pretend/usr/bin &&
567567
cp "$GIT_EXEC_PATH"/git.exe pretend/mingw64/bin/ &&
568568
cp "$GIT_EXEC_PATH"/git.exe pretend/mingw64/libexec/git-core/ &&
569+
# copy the .dll files, if any (happens when building via CMake)
570+
case "$GIT_EXEC_PATH"/*.dll in
571+
*/"*.dll") ;; # no `.dll` files to be copied
572+
*)
573+
cp "$GIT_EXEC_PATH"/*.dll pretend/mingw64/bin/ &&
574+
cp "$GIT_EXEC_PATH"/*.dll pretend/mingw64/libexec/git-core/
575+
;;
576+
esac &&
569577
echo "env | grep MSYSTEM=" | write_script "$HOME"/bin/git-test-home &&
570578
echo "echo mingw64" | write_script pretend/mingw64/bin/git-test-bin &&
571579
echo "echo usr" | write_script pretend/usr/bin/git-test-bin2 &&

t/test-lib.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,30 @@ 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
5867
fi
68+
if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR"
69+
then
70+
GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1
71+
# On Windows, we must convert Windows paths lest they contain a colon
72+
case "$(uname -s)" in
73+
*MINGW*)
74+
GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")"
75+
;;
76+
esac
77+
fi
5978

6079
# Prepend a string to a VAR using an arbitrary ":" delimiter, not
6180
# adding the delimiter if VAR or VALUE is empty. I.e. a generalized:

0 commit comments

Comments
 (0)