parallel-checkout: add tests for basic operations

Add tests to populate the working tree during clone and checkout using
sequential and parallel mode, to confirm that they produce identical
results. Also test basic checkout mechanics, such as checking for
symlinks in the leading directories and the abidance to --force.

Note: some helper functions are added to a common lib file which is only
included by t2080 for now. But they will also be used by other
parallel-checkout tests in the following patches.

Co-authored-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Matheus Tavares
2021-05-04 13:27:31 -03:00
committed by Junio C Hamano
parent 70b052b209
commit d0e5d35700
2 changed files with 271 additions and 0 deletions

View File

@ -0,0 +1,42 @@
# Helpers for tests invoking parallel-checkout
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 &&
local expected_workers=$1 &&
shift &&
local trace_file=trace-test-checkout-workers &&
rm -f "$trace_file" &&
GIT_TRACE2="$(pwd)/$trace_file" "$@" &&
local workers=$(grep "child_start\[..*\] git checkout--worker" "$trace_file" | wc -l) &&
test $workers -eq $expected_workers &&
rm "$trace_file"
}
# 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
}