Skip to content

Commit 5ce40d9

Browse files
matheustavaresgitster
authored andcommitted
ci: run test round with parallel-checkout enabled
We already have tests for the basic parallel-checkout operations. But this code can also run in other commands, such as git-read-tree and git-sparse-checkout, which are currently not tested with multiple workers. To promote a wider test coverage without duplicating tests: 1. Add the GIT_TEST_CHECKOUT_WORKERS environment variable, to optionally force parallel-checkout execution during the whole test suite. 2. Include this variable in the second test round of the linux-gcc job of our ci scripts. This round runs `make test` again with some optional GIT_TEST_* variables enabled, so there is no additional overhead in exercising the parallel-checkout code here. Note: the specific parallel-checkout tests t208* cannot be used in combination with GIT_TEST_CHECKOUT_WORKERS as they need to set and check the number of workers by themselves. So skip those tests when this flag is set. Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent db396cd commit 5ce40d9

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

ci/run-build-and-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ linux-gcc)
2222
export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
2323
export GIT_TEST_MULTI_PACK_INDEX=1
2424
export GIT_TEST_ADD_I_USE_BUILTIN=1
25+
export GIT_TEST_CHECKOUT_WORKERS=2
2526
make test
2627
;;
2728
linux-clang)

parallel-checkout.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ enum pc_status parallel_checkout_status(void)
3232

3333
void get_parallel_checkout_configs(int *num_workers, int *threshold)
3434
{
35+
char *env_workers = getenv("GIT_TEST_CHECKOUT_WORKERS");
36+
37+
if (env_workers && *env_workers) {
38+
if (strtol_i(env_workers, 10, num_workers)) {
39+
die("invalid value for GIT_TEST_CHECKOUT_WORKERS: '%s'",
40+
env_workers);
41+
}
42+
if (*num_workers < 1)
43+
*num_workers = online_cpus();
44+
45+
*threshold = 0;
46+
return;
47+
}
48+
3549
if (git_config_get_int("checkout.workers", num_workers))
3650
*num_workers = 1;
3751
else if (*num_workers < 1)

t/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to
425425
use in the test scripts. Recognized values for <hash-algo> are "sha1"
426426
and "sha256".
427427

428+
GIT_TEST_CHECKOUT_WORKERS=<n> overrides the 'checkout.workers' setting
429+
to <n> and 'checkout.thresholdForParallelism' to 0, forcing the
430+
execution of the parallel-checkout code.
431+
428432
Naming Tests
429433
------------
430434

t/lib-parallel-checkout.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Helpers for t208* tests
22

3+
if ! test -z "$GIT_TEST_CHECKOUT_WORKERS"
4+
then
5+
skip_all="skipping test, GIT_TEST_CHECKOUT_WORKERS is set"
6+
test_done
7+
fi
8+
39
# Runs `git -c checkout.workers=$1 -c checkout.thesholdForParallelism=$2 ${@:4}`
410
# and checks that the number of workers spawned is equal to $3.
511
git_pc()

t/t2081-parallel-checkout-collisions.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description='parallel-checkout collisions'
44

55
. ./test-lib.sh
6+
. "$TEST_DIRECTORY/lib-parallel-checkout.sh"
67

78
# When there are pathname collisions during a clone, Git should report a warning
89
# listing all of the colliding entries. The sequential code detects a collision

0 commit comments

Comments
 (0)