Skip to content

Commit 87094fc

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 be executed by 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. Set this variable (with a value of 2) in the second test round of our linux-gcc CI job. 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 that tests checking out less than two parallel-eligible entries will fall back to the sequential mode. Nevertheless, it's still a good exercise for the parallel-checkout framework as the fallback codepath also writes the queued entries using the parallel-checkout functions (only without spawning any worker). Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d590422 commit 87094fc

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

ci/run-build-and-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ linux-gcc)
2525
export GIT_TEST_ADD_I_USE_BUILTIN=1
2626
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
2727
export GIT_TEST_WRITE_REV_INDEX=1
28+
export GIT_TEST_CHECKOUT_WORKERS=2
2829
make test
2930
;;
3031
linux-clang)

parallel-checkout.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ static const int DEFAULT_NUM_WORKERS = 1;
3535

3636
void get_parallel_checkout_configs(int *num_workers, int *threshold)
3737
{
38+
char *env_workers = getenv("GIT_TEST_CHECKOUT_WORKERS");
39+
40+
if (env_workers && *env_workers) {
41+
if (strtol_i(env_workers, 10, num_workers)) {
42+
die("invalid value for GIT_TEST_CHECKOUT_WORKERS: '%s'",
43+
env_workers);
44+
}
45+
if (*num_workers < 1)
46+
*num_workers = online_cpus();
47+
48+
*threshold = 0;
49+
return;
50+
}
51+
3852
if (git_config_get_int("checkout.workers", num_workers))
3953
*num_workers = DEFAULT_NUM_WORKERS;
4054
else if (*num_workers < 1)

t/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ and "sha256".
436436
GIT_TEST_WRITE_REV_INDEX=<boolean>, when true enables the
437437
'pack.writeReverseIndex' setting.
438438

439+
GIT_TEST_CHECKOUT_WORKERS=<n> overrides the 'checkout.workers' setting
440+
to <n> and 'checkout.thresholdForParallelism' to 0, forcing the
441+
execution of the parallel-checkout code.
442+
439443
Naming Tests
440444
------------
441445

t/lib-parallel-checkout.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Helpers for tests invoking parallel-checkout
22

3+
# Parallel checkout tests need full control of the number of workers
4+
unset GIT_TEST_CHECKOUT_WORKERS
5+
36
set_checkout_config () {
47
if test $# -ne 2
58
then

0 commit comments

Comments
 (0)