Re: [PATCH 10/10] fsmonitor: test with sparse index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 13, 2021 at 7:01 AM Derrick Stolee via GitGitGadget
<gitgitgadget@xxxxxxxxx> wrote:
>
> From: Derrick Stolee <dstolee@xxxxxxxxxxxxx>
>
> During the effort to protect uses of the index to operate on a full
> index, we did not modify fsmonitor.c. This is because it already works
> effectively with only the change to index_name_stage_pos(). The only
> thing left to do is to test that it works correctly.
>
> These tests are added to demonstrate that the behavior is the same
> across a full index and a sparse index, but also that file modifications
> to a tracked directory outside of the sparse cone will trigger
> ensure_full_index().
>
> Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx>
> ---
>  t/t7519-status-fsmonitor.sh | 48 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>
> diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh
> index 23879d967297..306157d48abf 100755
> --- a/t/t7519-status-fsmonitor.sh
> +++ b/t/t7519-status-fsmonitor.sh
> @@ -78,6 +78,7 @@ test_expect_success 'setup' '
>         expect*
>         actual*
>         marker*
> +       trace2*
>         EOF
>  '
>
> @@ -400,4 +401,51 @@ test_expect_success 'status succeeds after staging/unstaging' '
>         )
>  '
>
> +test_expect_success 'status succeeds with sparse index' '
> +       test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&
> +       git status --porcelain=v2 >expect &&
> +       git sparse-checkout init --cone --sparse-index &&
> +       GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
> +               git status --porcelain=v2 >actual &&
> +       test_region ! index ensure_full_index trace2.txt &&
> +       test_cmp expect actual &&
> +       rm trace2.txt &&
> +
> +       write_script .git/hooks/fsmonitor-test<<-\EOF &&
> +               printf "last_update_token\0"
> +       EOF
> +       git config core.fsmonitor .git/hooks/fsmonitor-test &&
> +       git status --porcelain=v2 >expect &&
> +       git sparse-checkout init --cone --sparse-index &&
> +       GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
> +               git status --porcelain=v2 >actual &&
> +       test_region ! index ensure_full_index trace2.txt &&
> +       test_cmp expect actual &&
> +       rm trace2.txt &&
> +
> +       write_script .git/hooks/fsmonitor-test<<-\EOF &&
> +               printf "last_update_token\0"
> +               printf "dir1/modified\0"
> +       EOF
> +       git config core.fsmonitor .git/hooks/fsmonitor-test &&
> +       git status --porcelain=v2 >expect &&
> +       git sparse-checkout init --cone --sparse-index &&
> +       GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
> +               git status --porcelain=v2 >actual &&
> +       test_region ! index ensure_full_index trace2.txt &&
> +       test_cmp expect actual &&
> +
> +       write_script .git/hooks/fsmonitor-test<<-\EOF &&
> +               printf "last_update_token\0"
> +               printf "dir1a/modified\0"
> +       EOF
> +       git config core.fsmonitor .git/hooks/fsmonitor-test &&
> +       git status --porcelain=v2 >expect &&
> +       git sparse-checkout init --cone --sparse-index &&
> +       GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
> +               git status --porcelain=v2 >actual &&
> +       test_region index ensure_full_index trace2.txt &&
> +       test_cmp expect actual

There's a lot of duplicated lines here; would it make sense to have a
helper function you call, making it easier to see the differences
between the four subsections of this test?  Also, do you want to use
test_config instead of git config, so that it automatically gets unset
at the end of the test?



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux