Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,65 @@ CMake, either by letting Visual Studio configure it automatically (simply open G
top-level directory via `File>Open>Folder...`) or by (downloading and) running
[CMake](https://cmake.org) manually.

## Building and testing in Windows Subsystem for Linux ("WSL")

Install the Linux packages `gcc-mingw-w64-x86-64` and
`libz-mingw-w64-dev`. From the source directory in Linux Bash:

```bash
cross=x86_64-w64-mingw32
MSYSTEM=MINGW64 make -j"$(nproc)" uname_S=MINGW \
CC="$cross-gcc" AR="$cross-ar" RC="$cross-windres -O coff" \
MINGW_CHOST="$cross" NO_CURL=1 NO_GETTEXT=1 \
NO_ICONV=1 NO_OPENSSL=1 NO_PERL=1 NO_PYTHON=1 \
NO_RUST=1 NO_TCLTK=1 USE_LIBPCRE=
```

Prefer WSL Bash for speed. Use SDK Bash for Windows-specific prerequisites,
MSYS path handling or integrations such as `git svn` with Perl/SVN enabled.

### Run tests with WSL Bash

Install the Git for Windows SDK before testing.

```bash
sdk=/mnt/d/git-sdk-64
script=t0014-alias.sh
zlib=/usr/$cross/lib
ssp=$(dirname "$("$cross-gcc" -print-file-name=libssp-0.dll)")
output=$(mktemp -d)
(
export MSYSTEM=MINGW64 GIT_TEST_WSL=1
export TEST_OUTPUT_DIRECTORY="$output"
export PATH="$ssp:$zlib:$sdk/mingw64/bin:$sdk/usr/bin:$PATH"
export Path="$PATH"
export WSLENV=MSYSTEM:Path/pl
# -V will write the detailed output to t/test-results/<test>.out
cd t && time bash "$script" -iVx
)
```

Use `Path/pl`, not `PATH/pl`, to avoid duplicate Windows path entries.

### Run tests with Git SDK Bash

```bash
# MSYS2 `mkdir` cannot create directories in UNC paths; use $env:Temp
scratch=$(wslpath -u "$("$sdk/usr/bin/cygpath.exe" -m /tmp)")
output=$(mktemp -d -p "$scratch")
runtime="$(wslpath -m "$ssp"):$(wslpath -m "$zlib")"

(
cd t &&
time "$sdk/usr/bin/env.exe" MSYSTEM=MINGW64 \
"PATH=$runtime:/mingw64/bin:/usr/bin" \
"TEST_OUTPUT_DIRECTORY=$(wslpath -m "$output")" \
"GIT_TEST_TEMPLATE_DIR=$(wslpath -m "$PWD/../templates/blt")" \
"$(wslpath -m "$sdk")/usr/bin/bash.exe" \
"$script" -iVx --no-bin-wrappers
)
```

What to Change?
---------------

Expand Down
2 changes: 1 addition & 1 deletion GIT-BUILD-OPTIONS.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GIT_TEST_GITPERLLIB=@GIT_TEST_GITPERLLIB@
GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
GIT_TEST_OPTS=@GIT_TEST_OPTS@
GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
GIT_TEST_TEMPLATE_DIR=@GIT_TEST_TEMPLATE_DIR@
GIT_TEST_TEMPLATE_DIR=${GIT_TEST_TEMPLATE_DIR:-@GIT_TEST_TEMPLATE_DIR@}
GIT_TEST_TEXTDOMAINDIR=@GIT_TEST_TEXTDOMAINDIR@
GIT_TEST_UTF8_LOCALE=@GIT_TEST_UTF8_LOCALE@
LOCALEDIR=@LOCALEDIR@
Expand Down
20 changes: 20 additions & 0 deletions bin-wrappers/wrap-for-bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"

export MERGE_TOOLS_DIR GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR

if test "$GIT_TEST_WSL" = 1
then
export Path="$PATH"
if test -n "$TEST_OUTPUT_DIRECTORY"
then
safe=$(wslpath -m "$TEST_OUTPUT_DIRECTORY") || exit
safe=$(printf '%s' "$safe" | sed "s/'/'\\\\''/g") || exit
params="${GIT_CONFIG_PARAMETERS:+$GIT_CONFIG_PARAMETERS }"
export GIT_CONFIG_PARAMETERS="$params'safe.directory'='$safe/*'"
fi
WSLENV="$WSLENV:HOME/p:GITPERLLIB/pl:LANG:LC_ALL:TZ:TERM"
WSLENV="$WSLENV:EDITOR:PAGER:COLUMNS:$(env -0 | sed -zE '
/^(TEST|GIT)_/!d
s/=.*//
s/^GIT_(EXEC_PATH|TEMPLATE_DIR|TEXTDOMAINDIR)$/&\/p/
s/^GIT_CEILING_DIRECTORIES$/&\/pl/
' | tr '\0' :)"
export WSLENV
fi

case "$GIT_DEBUGGER" in
'')
exec "@PROG@" "$@"
Expand Down
8 changes: 8 additions & 0 deletions t/README
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ that cannot be easily covered by a few specific test cases. These
could be enabled by running the test suite with correct GIT_TEST_
environment set.

GIT_TEST_TEMPLATE_DIR=<path> overrides the generated location of the
templates used by the tests.

GIT_TEST_WSL=1 forwards the test environment when the generated wrappers
run Windows executables from WSL. It also grants a command-scope
safe.directory exception for repositories under TEST_OUTPUT_DIRECTORY.
See CONTRIBUTING.md for the cross-build and runner setup.

GIT_TEST_FAIL_PREREQS=<boolean> fails all prerequisites. This is
useful for discovering issues with the tests where say a later test
implicitly depends on an optional earlier test.
Expand Down
Loading