Skip to content

Commit

Permalink
t7519: add sparse directories to FS monitor tests
Browse files Browse the repository at this point in the history
The File System Monitor (FS Monitor) tests in t7519 demonstrate some
important interactions with the index and the response from the FS
Monitor hook. Later changes will integrate the FS Monitor extension in
the index with the existence of sparse directory entries in a sparse
index. To do so, we need to include directories outside of the sparse
checkout definition.

Add a new directory, dir1a, between dir1 and dir2 in the test repo used
by this script. By inserting it in the middle, we are more likely to
trigger incorrect behavior when the fsmonitor_dirty bitmap is involved
with sparse directories changing the position of cache entries.

I could have modified the test to create two repos, one sparse and one
not, but that causes confusion in the expected output. Further, it makes
the test take twice as long. With this approach, we can validate that FS
Monitor works with the sparse index feature using the
GIT_TEST_SPARSE_INDEX=1 environment variable.

Of course, we can't do that until 'git update-index' stops expanding a
sparse-index into a full index. This is because the FS Monitor bitmap
and other data is cleared entirely when the index is converted between
modes. When we later integrate 'git update-index' with the sparse-index,
then we can update this test to be more informative.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Jun 4, 2021
1 parent eaf49fc commit 30b72ab
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions t/t7519-status-fsmonitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ test_description='git status with file system watcher'

. ./test-lib.sh

# Until 'git update-index' stops expanding a sparse-index into
# a full one, the fsmonitor data will be wiped clean during each
# of those commands. This causes this test to not work correctly
# with GIT_TEST_SPLIT_INDEX=1, so disable it for now. Later, we
# will integrate properly with that command and allow it to be
# enabled.
GIT_TEST_SPLIT_INDEX=0

# Note, after "git reset --hard HEAD" no extensions exist other than 'TREE'
# "git update-index --fsmonitor" can be used to get the extension written
# before testing the results.
Expand Down Expand Up @@ -62,11 +70,16 @@ test_expect_success 'setup' '
mkdir dir1 &&
: >dir1/tracked &&
: >dir1/modified &&
mkdir dir1a &&
: >dir1a/a &&
: >dir1a/b &&
mkdir dir2 &&
: >dir2/tracked &&
: >dir2/modified &&
git -c core.fsmonitor= add . &&
git -c core.fsmonitor= commit -m initial &&
git sparse-checkout init --cone --no-sparse-index &&
git sparse-checkout set dir1 dir2 &&
git config core.fsmonitor .git/hooks/fsmonitor-test &&
cat >.gitignore <<-\EOF
.gitignore
Expand Down Expand Up @@ -100,6 +113,8 @@ test_expect_success 'update-index --no-fsmonitor" removes the fsmonitor extensio
cat >expect <<EOF &&
h dir1/modified
H dir1/tracked
S dir1a/a
S dir1a/b
h dir2/modified
H dir2/tracked
h modified
Expand All @@ -122,6 +137,8 @@ test_expect_success 'update-index --fsmonitor-valid" sets the fsmonitor valid bi
cat >expect <<EOF &&
H dir1/modified
H dir1/tracked
S dir1a/a
S dir1a/b
H dir2/modified
H dir2/tracked
H modified
Expand All @@ -140,6 +157,8 @@ test_expect_success 'update-index --no-fsmonitor-valid" clears the fsmonitor val
cat >expect <<EOF &&
H dir1/modified
H dir1/tracked
S dir1a/a
S dir1a/b
H dir2/modified
H dir2/tracked
H modified
Expand All @@ -159,6 +178,8 @@ cat >expect <<EOF &&
H dir1/modified
h dir1/new
H dir1/tracked
S dir1a/a
S dir1a/b
H dir2/modified
h dir2/new
H dir2/tracked
Expand All @@ -183,6 +204,8 @@ cat >expect <<EOF &&
H dir1/modified
h dir1/new
h dir1/tracked
S dir1a/a
S dir1a/b
H dir2/modified
h dir2/new
h dir2/tracked
Expand All @@ -202,6 +225,8 @@ test_expect_success 'all unmodified files get marked valid' '
cat >expect <<EOF &&
H dir1/modified
h dir1/tracked
S dir1a/a
S dir1a/b
h dir2/modified
h dir2/tracked
h modified
Expand Down

0 comments on commit 30b72ab

Please sign in to comment.