From 6cb2f72cf9461bba65701fc88b8b94c1147a1813 Mon Sep 17 00:00:00 2001 From: Tobias Kaupat Date: Sat, 17 Oct 2026 23:27:02 +0200 Subject: [PATCH] fix: make the test suites work on Windows/Git-Bash out of the box MSYS rewrites POSIX-looking arguments before docker sees them, so `docker exec /usr/bin/backup` arrived as `C:/Program Files/Git/usr/bin/backup` and the structure suite could not read `--config /test/structure.yml`. 23 of 32 compat assertions and the whole structure suite failed on Git-Bash, while test/lib.sh claimed the suites behave identically on every platform. test/lib.sh and test/run.sh now export MSYS_NO_PATHCONV=1 and MSYS2_ARG_CONV_EXCL='*' themselves - lib.sh for the suites that source it, run.sh for its own docker calls and the suites it starts as separate processes. Both variables are ignored on Linux and macOS. README documents that nothing has to be exported by hand. Verified on Git-Bash without any variable set in the environment: structure 13/13, compat 32/32, features 4 SKIP, exit 0, and `bash test/run.sh --sabotage` still reports "sabotage check ok". Co-Authored-By: Claude Opus 5 (1M context) Agent-Id: agent-4966d0e6-7f4d-4b37-be3d-0648ed56cb8a --- README.md | 6 ++++++ test/lib.sh | 9 +++++++++ test/run.sh | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 960edbd..2ff88d0 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ bash test/run.sh --no-build # reuse an already built image bash test/run.sh --suite compat # run a single suite ``` +They run unchanged on Linux, macOS and Windows/Git-Bash. On Git-Bash the +scripts set `MSYS_NO_PATHCONV=1` and `MSYS2_ARG_CONV_EXCL='*'` themselves, +because MSYS would otherwise rewrite container paths such as +`/usr/bin/backup` into `C:/Program Files/Git/usr/bin/backup` before `docker` +sees them. Nothing has to be exported by hand. + There are three suites: * **compat** (`test/compat.sh`) - backup, restore, forget, check, hooks and diff --git a/test/lib.sh b/test/lib.sh index 71d6fc1..5acc01b 100644 --- a/test/lib.sh +++ b/test/lib.sh @@ -4,6 +4,15 @@ # Deliberately dependency-free: bash + docker only. No test framework, no # host-side bind mounts (files are moved with `docker cp`) so the suites behave # identically on Linux CI runners, macOS and Windows/Git-Bash. +# +# Windows/Git-Bash needs one extra thing: MSYS rewrites every argument that +# looks like a POSIX path before the process sees it, so +# `docker exec /usr/bin/backup` reaches the daemon as +# `C:/Program Files/Git/usr/bin/backup` and the container command is not found. +# Both variables are required (one covers the command, one covers its +# arguments) and both are ignored on Linux and macOS. +export MSYS_NO_PATHCONV=1 +export MSYS2_ARG_CONV_EXCL='*' IMAGE="${IMAGE:-restic-backup-docker:test}" diff --git a/test/run.sh b/test/run.sh index 5295f1b..0cba1a6 100644 --- a/test/run.sh +++ b/test/run.sh @@ -12,6 +12,14 @@ set -u +# Windows/Git-Bash: MSYS mangles POSIX-looking arguments on their way to the +# docker daemon, which breaks `docker exec` and `--config /test/structure.yml`. +# lib.sh exports the same two variables for the suites that source it; run.sh +# calls docker itself and starts the suites as separate processes, so it needs +# them as well. Both are ignored on Linux and macOS. +export MSYS_NO_PATHCONV=1 +export MSYS2_ARG_CONV_EXCL='*' + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" IMAGE="${IMAGE:-restic-backup-docker:test}"