2021-05-04 16:27:31 +00:00
|
|
|
# Helpers for tests invoking parallel-checkout
|
|
|
|
|
2021-05-04 16:27:35 +00:00
|
|
|
# Parallel checkout tests need full control of the number of workers
|
|
|
|
unset GIT_TEST_CHECKOUT_WORKERS
|
|
|
|
|
2021-05-04 16:27:31 +00:00
|
|
|
set_checkout_config () {
|
|
|
|
if test $# -ne 2
|
|
|
|
then
|
|
|
|
BUG "usage: set_checkout_config <workers> <threshold>"
|
|
|
|
fi &&
|
|
|
|
|
|
|
|
test_config_global checkout.workers $1 &&
|
|
|
|
test_config_global checkout.thresholdForParallelism $2
|
|
|
|
}
|
|
|
|
|
|
|
|
# Run "${@:2}" and check that $1 checkout workers were used
|
|
|
|
test_checkout_workers () {
|
|
|
|
if test $# -lt 2
|
|
|
|
then
|
|
|
|
BUG "too few arguments to test_checkout_workers"
|
|
|
|
fi &&
|
|
|
|
|
2024-04-06 00:08:59 +00:00
|
|
|
local expected_workers="$1" &&
|
2021-05-04 16:27:31 +00:00
|
|
|
shift &&
|
|
|
|
|
|
|
|
local trace_file=trace-test-checkout-workers &&
|
|
|
|
rm -f "$trace_file" &&
|
2022-07-14 11:49:11 +00:00
|
|
|
(
|
|
|
|
GIT_TRACE2="$(pwd)/$trace_file" &&
|
|
|
|
export GIT_TRACE2 &&
|
|
|
|
"$@" 2>&8
|
|
|
|
) &&
|
2021-05-04 16:27:31 +00:00
|
|
|
|
2021-06-06 01:01:57 +00:00
|
|
|
local workers="$(grep "child_start\[..*\] git checkout--worker" "$trace_file" | wc -l)" &&
|
2021-05-04 16:27:31 +00:00
|
|
|
test $workers -eq $expected_workers &&
|
|
|
|
rm "$trace_file"
|
2021-05-04 16:27:32 +00:00
|
|
|
} 8>&2 2>&4
|
2021-05-04 16:27:31 +00:00
|
|
|
|
|
|
|
# Verify that both the working tree and the index were created correctly
|
|
|
|
verify_checkout () {
|
|
|
|
if test $# -ne 1
|
|
|
|
then
|
|
|
|
BUG "usage: verify_checkout <repository path>"
|
|
|
|
fi &&
|
|
|
|
|
|
|
|
git -C "$1" diff-index --ignore-submodules=none --exit-code HEAD -- &&
|
|
|
|
git -C "$1" status --porcelain >"$1".status &&
|
|
|
|
test_must_be_empty "$1".status
|
|
|
|
}
|