diff mbox series

[v2,12/13] submodule update: add tests for --filter

Message ID 20220301044132.39474-13-chooglen@google.com (mailing list archive)
State Superseded
Headers show
Series submodule: convert parts of 'update' to C | expand

Commit Message

Glen Choo March 1, 2022, 4:41 a.m. UTC
Test the "--filter" option to make sure we don't break anything while
refactoring "git submodule update".

Signed-off-by: Glen Choo <chooglen@google.com>
---
 t/t7406-submodule-update.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Ævar Arnfjörð Bjarmason March 1, 2022, 8:07 a.m. UTC | #1
On Mon, Feb 28 2022, Glen Choo wrote:

> Test the "--filter" option to make sure we don't break anything while
> refactoring "git submodule update".
>
> Signed-off-by: Glen Choo <chooglen@google.com>
> ---
>  t/t7406-submodule-update.sh | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> index 7764c1c3cb..6cc60ff5e5 100755
> --- a/t/t7406-submodule-update.sh
> +++ b/t/t7406-submodule-update.sh
> @@ -1071,4 +1071,17 @@ test_expect_success 'submodule update --quiet passes quietness to fetch with a s
>  	)
>  '
>  
> +test_expect_success 'submodule update --filter requires --init' '
> +	test_must_fail git -C super submodule update --filter blob:none 2>err &&

Should be "test_expect_code 129" (presumably, or is it 128). In any case
other similar "usage" test check for that:

> +	grep "usage:" err

We could retain this then, but FWIW if it's 129 other tests consider it
redundant.
Glen Choo March 1, 2022, 6:30 p.m. UTC | #2
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> On Mon, Feb 28 2022, Glen Choo wrote:
>
>> Test the "--filter" option to make sure we don't break anything while
>> refactoring "git submodule update".
>>
>> Signed-off-by: Glen Choo <chooglen@google.com>
>> ---
>>  t/t7406-submodule-update.sh | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
>> index 7764c1c3cb..6cc60ff5e5 100755
>> --- a/t/t7406-submodule-update.sh
>> +++ b/t/t7406-submodule-update.sh
>> @@ -1071,4 +1071,17 @@ test_expect_success 'submodule update --quiet passes quietness to fetch with a s
>>  	)
>>  '
>>  
>> +test_expect_success 'submodule update --filter requires --init' '
>> +	test_must_fail git -C super submodule update --filter blob:none 2>err &&
>
> Should be "test_expect_code 129" (presumably, or is it 128). In any case
> other similar "usage" test check for that:
>
>> +	grep "usage:" err
>
> We could retain this then, but FWIW if it's 129 other tests consider it
> redundant.

Ah, thanks for the tip. I forgot that this is how we check for usage.
diff mbox series

Patch

diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 7764c1c3cb..6cc60ff5e5 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -1071,4 +1071,17 @@  test_expect_success 'submodule update --quiet passes quietness to fetch with a s
 	)
 '
 
+test_expect_success 'submodule update --filter requires --init' '
+	test_must_fail git -C super submodule update --filter blob:none 2>err &&
+	grep "usage:" err
+'
+
+test_expect_success 'submodule update --filter sets partial clone settings' '
+	test_when_finished "rm -rf super-filter" &&
+	git clone cloned super-filter &&
+	git -C super-filter submodule update --init --filter blob:none &&
+	test_cmp_config -C super-filter/submodule true remote.origin.promisor &&
+	test_cmp_config -C super-filter/submodule blob:none remote.origin.partialclonefilter
+'
+
 test_done