Fixes for tests when the source directory has unusual characters in
its path, e.g. whitespaces, double-quotes, etc.
source: <cover-v2-0.3-
00000000000-20220630T101646Z-avarab@gmail.com>
* ab/test-quoting-fix:
config tests: fix harmless but broken "rm -r" cleanup
test-lib.sh: fix prepend_var() quoting issue
tests: add missing double quotes to included library paths
'
test_expect_success 'override global and system config' '
- test_when_finished rm -f "$HOME"/.config/git &&
-
+ test_when_finished rm -f \"\$HOME\"/.gitconfig &&
cat >"$HOME"/.gitconfig <<-EOF &&
[home]
config = true
EOF
+
+ test_when_finished rm -rf \"\$HOME\"/.config/git &&
mkdir -p "$HOME"/.config/git &&
cat >"$HOME"/.config/git/config <<-EOF &&
[xdg]
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
-. $TEST_DIRECTORY/lib-unique-files.sh
+. "$TEST_DIRECTORY"/lib-unique-files.sh
# Test the file mode "$1" of the file "$2" in the index.
test_mode_in_index () {
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
-. $TEST_DIRECTORY/lib-unique-files.sh
+. "$TEST_DIRECTORY"/lib-unique-files.sh
test_expect_success 'usage on cmd and subcommand invalid option' '
test_expect_code 129 git stash --invalid-option 2>usage &&
. ./test-lib.sh
test_expect_success 'mergetool --tool=vimdiff creates the expected layout' '
- . $GIT_BUILD_DIR/mergetools/vimdiff &&
+ . "$GIT_BUILD_DIR"/mergetools/vimdiff &&
run_unit_tests
'
#
# prepend_var VAR : VALUE
prepend_var () {
- eval "$1=$3\${$1:+${3:+$2}\$$1}"
+ eval "$1=\"$3\${$1:+${3:+$2}\$$1}\""
}
# If [AL]SAN is in effect we want to abort so that we notice
# problems. The GIT_SAN_OPTIONS variable can be used to set common
# defaults shared between [AL]SAN_OPTIONS.
prepend_var GIT_SAN_OPTIONS : abort_on_error=1
-prepend_var GIT_SAN_OPTIONS : strip_path_prefix=\"$GIT_BUILD_DIR/\"
+prepend_var GIT_SAN_OPTIONS : strip_path_prefix="$GIT_BUILD_DIR/"
# If we were built with ASAN, it may complain about leaks
# of program-lifetime variables. Disable it by default to lower