t1092: compare sparse-checkout to sparse-index

Add a new 'sparse-index' repo alongside the 'full-checkout' and 'sparse-checkout' repos in t1092-sparse-checkout-compatibility.sh. Also add run_on_sparse and test_sparse_match helpers. These helpers will be used when the sparse index is implemented. Add the GIT_TEST_SPARSE_INDEX environment variable to enable the sparse-index by default. This can be enabled across all tests, but that will only affect cases where the sparse-checkout feature is enabled. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Mar 30, 2021 at 13:10 UTC ecfc47c0667f9a580abaca0472f68efa0a8784e8
2 files changed +23 -4
t/README
+3
@@ -439,6 +439,9 @@ and "sha256".
439 GIT_TEST_WRITE_REV_INDEX=<boolean>, when true enables the
440 'pack.writeReverseIndex' setting.
441
442 +GIT_TEST_SPARSE_INDEX=<boolean>, when true enables index writes to use the
443 +sparse-index format by default.
444 +
445 Naming Tests
446 ------------
447
t/t1092-sparse-checkout-compatibility.sh
+20 -4
@@ -7,6 +7,7 @@ test_description='compare full workdir to sparse workdir'
7 test_expect_success 'setup' '
8 git init initial-repo &&
9 (
10 + GIT_TEST_SPARSE_INDEX=0 &&
11 cd initial-repo &&
12 echo a >a &&
13 echo "after deep" >e &&
@@ -87,23 +88,32 @@ init_repos () {
88
89 cp -r initial-repo sparse-checkout &&
90 git -C sparse-checkout reset --hard &&
90 - git -C sparse-checkout sparse-checkout init --cone &&
91 +
92 + cp -r initial-repo sparse-index &&
93 + git -C sparse-index reset --hard &&
94
95 # initialize sparse-checkout definitions
93 - git -C sparse-checkout sparse-checkout set deep
96 + git -C sparse-checkout sparse-checkout init --cone &&
97 + git -C sparse-checkout sparse-checkout set deep &&
98 + GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout init --cone &&
99 + GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep
100 }
101
102 run_on_sparse () {
103 (
104 cd sparse-checkout &&
99 - "$@" >../sparse-checkout-out 2>../sparse-checkout-err
105 + GIT_TEST_SPARSE_INDEX=0 "$@" >../sparse-checkout-out 2>../sparse-checkout-err
106 + ) &&
107 + (
108 + cd sparse-index &&
109 + GIT_TEST_SPARSE_INDEX=1 "$@" >../sparse-index-out 2>../sparse-index-err
110 )
111 }
112
113 run_on_all () {
114 (
115 cd full-checkout &&
106 - "$@" >../full-checkout-out 2>../full-checkout-err
116 + GIT_TEST_SPARSE_INDEX=0 "$@" >../full-checkout-out 2>../full-checkout-err
117 ) &&
118 run_on_sparse "$@"
119 }
@@ -114,6 +124,12 @@ test_all_match () {
124 test_cmp full-checkout-err sparse-checkout-err
125 }
126
127 +test_sparse_match () {
128 + run_on_sparse "$@" &&
129 + test_cmp sparse-checkout-out sparse-index-out &&
130 + test_cmp sparse-checkout-err sparse-index-err
131 +}
132 +
133 test_expect_success 'status with options' '
134 init_repos &&
135 test_all_match git status --porcelain=v2 &&