Matheus Tavares | d0e5d35 | 2021-05-04 13:27:31 -0300 | [diff] [blame] | 1 | # Helpers for tests invoking parallel-checkout |
| 2 | |
Matheus Tavares | 87094fc | 2021-05-04 13:27:35 -0300 | [diff] [blame] | 3 | # Parallel checkout tests need full control of the number of workers |
| 4 | unset GIT_TEST_CHECKOUT_WORKERS |
| 5 | |
Matheus Tavares | d0e5d35 | 2021-05-04 13:27:31 -0300 | [diff] [blame] | 6 | set_checkout_config () { |
| 7 | if test $# -ne 2 |
| 8 | then |
| 9 | BUG "usage: set_checkout_config <workers> <threshold>" |
| 10 | fi && |
| 11 | |
| 12 | test_config_global checkout.workers $1 && |
| 13 | test_config_global checkout.thresholdForParallelism $2 |
| 14 | } |
| 15 | |
| 16 | # Run "${@:2}" and check that $1 checkout workers were used |
| 17 | test_checkout_workers () { |
| 18 | if test $# -lt 2 |
| 19 | then |
| 20 | BUG "too few arguments to test_checkout_workers" |
| 21 | fi && |
| 22 | |
Junio C Hamano | 341aad8 | 2024-04-05 17:08:59 -0700 | [diff] [blame] | 23 | local expected_workers="$1" && |
Matheus Tavares | d0e5d35 | 2021-05-04 13:27:31 -0300 | [diff] [blame] | 24 | shift && |
| 25 | |
| 26 | local trace_file=trace-test-checkout-workers && |
| 27 | rm -f "$trace_file" && |
Matheus Tavares | 11d14de | 2022-07-14 08:49:11 -0300 | [diff] [blame] | 28 | ( |
| 29 | GIT_TRACE2="$(pwd)/$trace_file" && |
| 30 | export GIT_TRACE2 && |
| 31 | "$@" 2>&8 |
| 32 | ) && |
Matheus Tavares | d0e5d35 | 2021-05-04 13:27:31 -0300 | [diff] [blame] | 33 | |
René Scharfe | ebee558 | 2021-06-06 03:01:57 +0200 | [diff] [blame] | 34 | local workers="$(grep "child_start\[..*\] git checkout--worker" "$trace_file" | wc -l)" && |
Matheus Tavares | d0e5d35 | 2021-05-04 13:27:31 -0300 | [diff] [blame] | 35 | test $workers -eq $expected_workers && |
| 36 | rm "$trace_file" |
Matheus Tavares | 6a7bc9d | 2021-05-04 13:27:32 -0300 | [diff] [blame] | 37 | } 8>&2 2>&4 |
Matheus Tavares | d0e5d35 | 2021-05-04 13:27:31 -0300 | [diff] [blame] | 38 | |
| 39 | # Verify that both the working tree and the index were created correctly |
| 40 | verify_checkout () { |
| 41 | if test $# -ne 1 |
| 42 | then |
| 43 | BUG "usage: verify_checkout <repository path>" |
| 44 | fi && |
| 45 | |
| 46 | git -C "$1" diff-index --ignore-submodules=none --exit-code HEAD -- && |
| 47 | git -C "$1" status --porcelain >"$1".status && |
| 48 | test_must_be_empty "$1".status |
| 49 | } |