diff mbox series

[3/3] t5312: prepare for reftable

Message ID b2c6e14c7e7752c9e42cb38372edc8971895932f.1643651420.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit eaf0e83009f37263849be5d4bf6c394b73546bd3
Headers show
Series reftable related test tweaks | expand

Commit Message

Han-Wen Nienhuys Jan. 31, 2022, 5:50 p.m. UTC
From: Han-Wen Nienhuys <hanwen@google.com>

Mark some tests as REFFILES if they rely on packed refs. Use ref-store
helper to create bogus refs.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 t/t5312-prune-corruption.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Feb. 1, 2022, 9:17 p.m. UTC | #1
On Mon, Jan 31 2022, Han-Wen Nienhuys via GitGitGadget wrote:

> From: Han-Wen Nienhuys <hanwen@google.com>
>
> Mark some tests as REFFILES if they rely on packed refs. Use ref-store
> helper to create bogus refs.
>
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
>  t/t5312-prune-corruption.sh | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh
> index ea889c088a5..9d8e249ae8b 100755
> --- a/t/t5312-prune-corruption.sh
> +++ b/t/t5312-prune-corruption.sh
> @@ -22,8 +22,8 @@ test_expect_success 'disable reflogs' '
>  '
>  
>  create_bogus_ref () {
> -	test_when_finished 'rm -f .git/refs/heads/bogus..name' &&
> -	echo $bogus >.git/refs/heads/bogus..name
> +	test-tool ref-store main update-ref msg "refs/heads/bogus..name" $bogus $ZERO_OID REF_SKIP_REFNAME_VERIFICATION &&
> +	test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/bogus..name"
>  }
>  
>  test_expect_success 'create history reachable only from a bogus-named ref' '
> @@ -113,7 +113,7 @@ test_expect_success 'pack-refs does not silently delete broken loose ref' '
>  # we do not want to count on running pack-refs to
>  # actually pack it, as it is perfectly reasonable to
>  # skip processing a broken ref
> -test_expect_success 'create packed-refs file with broken ref' '
> +test_expect_success REFFILES 'create packed-refs file with broken ref' '
>  	rm -f .git/refs/heads/main &&
>  	cat >.git/packed-refs <<-EOF &&
>  	$missing refs/heads/main
> @@ -124,13 +124,13 @@ test_expect_success 'create packed-refs file with broken ref' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success 'pack-refs does not silently delete broken packed ref' '
> +test_expect_success REFFILES 'pack-refs does not silently delete broken packed ref' '
>  	git pack-refs --all --prune &&
>  	git rev-parse refs/heads/main >actual &&
>  	test_cmp expect actual
>  '
>  
> -test_expect_success 'pack-refs does not drop broken refs during deletion' '
> +test_expect_success REFFILES  'pack-refs does not drop broken refs during deletion' '
>  	git update-ref -d refs/heads/other &&
>  	git rev-parse refs/heads/main >actual &&
>  	test_cmp expect actual

The setup for these is reffiles-specific, but it seems to me this is
something we'd really like to test with reftable rather than skipping it
entirely.

I.e. the scenario described in the "we create..." comment in this file
is something that might happen with reftable too, no?
Han-Wen Nienhuys Feb. 3, 2022, 2:24 p.m. UTC | #2
On Tue, Feb 1, 2022 at 10:19 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:

> > -test_expect_success 'pack-refs does not drop broken refs during deletion' '
> > +test_expect_success REFFILES  'pack-refs does not drop broken refs during deletion' '
> >       git update-ref -d refs/heads/other &&
> >       git rev-parse refs/heads/main >actual &&
> >       test_cmp expect actual
>
> The setup for these is reffiles-specific, but it seems to me this is
> something we'd really like to test with reftable rather than skipping it
> entirely.
>
> I.e. the scenario described in the "we create..." comment in this file
> is something that might happen with reftable too, no?

That is tested in the 3 tests right above the ones I marked with
REFFILES ('pack-refs does not silently delete broken loose ref'). The
tests at the bottom check what happens if you have a missing SHA1 in a
packed-refs file. The reftable backend does not have a packed-refs, so
there is nothing to test.
Junio C Hamano Feb. 3, 2022, 6:31 p.m. UTC | #3
Han-Wen Nienhuys <hanwen@google.com> writes:

> On Tue, Feb 1, 2022 at 10:19 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>
>> > -test_expect_success 'pack-refs does not drop broken refs during deletion' '
>> > +test_expect_success REFFILES  'pack-refs does not drop broken refs during deletion' '
>> >       git update-ref -d refs/heads/other &&
>> >       git rev-parse refs/heads/main >actual &&
>> >       test_cmp expect actual
>>
>> The setup for these is reffiles-specific, but it seems to me this is
>> something we'd really like to test with reftable rather than skipping it
>> entirely.
>>
>> I.e. the scenario described in the "we create..." comment in this file
>> is something that might happen with reftable too, no?
>
> That is tested in the 3 tests right above the ones I marked with
> REFFILES ('pack-refs does not silently delete broken loose ref'). The
> tests at the bottom check what happens if you have a missing SHA1 in a
> packed-refs file. The reftable backend does not have a packed-refs, so
> there is nothing to test.

Yup.  The patch posted looked good to me.

Thanks for writing and reviewing.
diff mbox series

Patch

diff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh
index ea889c088a5..9d8e249ae8b 100755
--- a/t/t5312-prune-corruption.sh
+++ b/t/t5312-prune-corruption.sh
@@ -22,8 +22,8 @@  test_expect_success 'disable reflogs' '
 '
 
 create_bogus_ref () {
-	test_when_finished 'rm -f .git/refs/heads/bogus..name' &&
-	echo $bogus >.git/refs/heads/bogus..name
+	test-tool ref-store main update-ref msg "refs/heads/bogus..name" $bogus $ZERO_OID REF_SKIP_REFNAME_VERIFICATION &&
+	test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/bogus..name"
 }
 
 test_expect_success 'create history reachable only from a bogus-named ref' '
@@ -113,7 +113,7 @@  test_expect_success 'pack-refs does not silently delete broken loose ref' '
 # we do not want to count on running pack-refs to
 # actually pack it, as it is perfectly reasonable to
 # skip processing a broken ref
-test_expect_success 'create packed-refs file with broken ref' '
+test_expect_success REFFILES 'create packed-refs file with broken ref' '
 	rm -f .git/refs/heads/main &&
 	cat >.git/packed-refs <<-EOF &&
 	$missing refs/heads/main
@@ -124,13 +124,13 @@  test_expect_success 'create packed-refs file with broken ref' '
 	test_cmp expect actual
 '
 
-test_expect_success 'pack-refs does not silently delete broken packed ref' '
+test_expect_success REFFILES 'pack-refs does not silently delete broken packed ref' '
 	git pack-refs --all --prune &&
 	git rev-parse refs/heads/main >actual &&
 	test_cmp expect actual
 '
 
-test_expect_success 'pack-refs does not drop broken refs during deletion' '
+test_expect_success REFFILES  'pack-refs does not drop broken refs during deletion' '
 	git update-ref -d refs/heads/other &&
 	git rev-parse refs/heads/main >actual &&
 	test_cmp expect actual