diff mbox series

[1/4] t5411: start using the default branch name "main"

Message ID f997166db4c29d971a2343f70c9d9a0505a8cc4b.1603839487.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Adjust t5411 for the upcoming change of the default branch name | expand

Commit Message

Johannes Schindelin Oct. 27, 2020, 10:58 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

This is a straight-forward search-and-replace in the test script;
However, this is not yet complete because it requires many more
replacements in `t/t5411/`, too many for a single patch (the Git mailing
list rejects mails larger than 100kB). For that reason, we disable this
test script temporarily via the `PREPARE_FOR_MAIN_BRANCH` prereq.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t5411-proc-receive-hook.sh | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Comments

Junio C Hamano Oct. 28, 2020, 8 p.m. UTC | #1
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> This is a straight-forward search-and-replace in the test script;
> However, this is not yet complete because it requires many more
> replacements in `t/t5411/`, too many for a single patch (the Git mailing
> list rejects mails larger than 100kB). For that reason, we disable this
> test script temporarily via the `PREPARE_FOR_MAIN_BRANCH` prereq.

I do not think it matters too much, as it will become correct at the
end anyway, but ... 

> +test_have_prereq PREPARE_FOR_MAIN_BRANCH || {
> +	test_skip="In transit for the default branch name 'main'"
> +	test_done
> +}
> +

... the way I read the introductory paragraph in the proposed log
message is that the point of adding a protection here (done in order
to work around a transient failure caused by having to artificially
split this topic into four patches) is to avoid an inevitable
failure due to some parts of tests adjusted for 'main' while other
parts still expect 'master'.  Until files in t/5411/* gets adjusted
for 'main', nothing is expected to pass whether the default branch
is 'master' or 'main'.  Or with only 1/4 applied, is this test
expected to pass if GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set to
'main' (i.e. PREPARE_FOR_MAIN_BRANCH prerequisite is satisfied)?

IOW, I do not see the point in _conditionally_ skipping the rest of
the test in this step.  I'd however understand it if we always skip
the rest in 1/4 and then enable the rest only when testing with
'main' as the default in 4/4, when all the necessary pieces in
t/t5411 have been converted.

The "straight-forward search-and-replace" part looks obviously good,
of course.

Thanks.

>  . "$TEST_DIRECTORY"/t5411/common-functions.sh
>  
>  setup_upstream_and_workbench () {
> -	# Refs of upstream : master(A)
> -	# Refs of workbench: master(A)  tags/v123
> +	# Refs of upstream : main(A)
> +	# Refs of workbench: main(A)  tags/v123
>  	test_expect_success "setup upstream and workbench" '
>  		rm -rf upstream.git &&
>  		rm -rf workbench &&
> @@ -25,10 +30,10 @@ setup_upstream_and_workbench () {
>  			git config core.abbrev 7 &&
>  			git tag -m "v123" v123 $A &&
>  			git remote add origin ../upstream.git &&
> -			git push origin master &&
> -			git update-ref refs/heads/master $A $B &&
> +			git push origin main &&
> +			git update-ref refs/heads/main $A $B &&
>  			git -C ../upstream.git update-ref \
> -				refs/heads/master $A $B
> +				refs/heads/main $A $B
>  		) &&
>  		TAG=$(git -C workbench rev-parse v123) &&
>  
> @@ -99,8 +104,8 @@ start_httpd
>  # Re-initialize the upstream repository and local workbench.
>  setup_upstream_and_workbench
>  
> -# Refs of upstream : master(A)
> -# Refs of workbench: master(A)  tags/v123
> +# Refs of upstream : main(A)
> +# Refs of workbench: main(A)  tags/v123
>  test_expect_success "setup for HTTP protocol" '
>  	git -C upstream.git config http.receivepack true &&
>  	upstream="$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" &&
Junio C Hamano Oct. 28, 2020, 8:12 p.m. UTC | #2
Junio C Hamano <gitster@pobox.com> writes:

>> +test_have_prereq PREPARE_FOR_MAIN_BRANCH || {
>> +	test_skip="In transit for the default branch name 'main'"
>> +	test_done
>> +}
>> +
>
> IOW, I do not see the point in _conditionally_ skipping the rest of
> the test in this step.  I'd however understand it if we always skip
> the rest in 1/4 and then enable the rest only when testing with
> 'main' as the default in 4/4, when all the necessary pieces in
> t/t5411 have been converted.

Another way to protect the test well would be to keep the "unless
testing with master, skip all" prerequisite check you wrote above,
but add

    GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master

immediately before that.  We can flip it to use 'master' at the
final step in the series.

That way, we will not be affected by the GIT_TEST_* environment
variable that is passed to these scripts by the tester.  I think
I'd prefer to do it that way, instead of unconditionally skipping,
as the result would be more self explanatory.

Thanks.
Johannes Schindelin Oct. 30, 2020, 3:04 p.m. UTC | #3
Hi Junio,

On Wed, 28 Oct 2020, Junio C Hamano wrote:

> Junio C Hamano <gitster@pobox.com> writes:
>
> >> +test_have_prereq PREPARE_FOR_MAIN_BRANCH || {
> >> +	test_skip="In transit for the default branch name 'main'"
> >> +	test_done
> >> +}
> >> +
> >
> > IOW, I do not see the point in _conditionally_ skipping the rest of
> > the test in this step.  I'd however understand it if we always skip
> > the rest in 1/4 and then enable the rest only when testing with
> > 'main' as the default in 4/4, when all the necessary pieces in
> > t/t5411 have been converted.
>
> Another way to protect the test well would be to keep the "unless
> testing with master, skip all" prerequisite check you wrote above,
> but add
>
>     GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
>
> immediately before that.  We can flip it to use 'master' at the
> final step in the series.
>
> That way, we will not be affected by the GIT_TEST_* environment
> variable that is passed to these scripts by the tester.  I think
> I'd prefer to do it that way, instead of unconditionally skipping,
> as the result would be more self explanatory.

Do you mean that this patch, squashed into 1/4:

-- snip --
diff --git a/t/t5411-proc-receive-hook.sh b/t/t5411-proc-receive-hook.sh
index 06bbb02ed22..6da6f597a50 100755
--- a/t/t5411-proc-receive-hook.sh
+++ b/t/t5411-proc-receive-hook.sh
@@ -5,6 +5,9 @@

 test_description='Test proc-receive hook'

+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 . ./test-lib.sh

 test_have_prereq PREPARE_FOR_MAIN_BRANCH || {

-- snap --

so that 4/4 starts with:

-- snip --
diff --git a/t/t5411-proc-receive-hook.sh b/t/t5411-proc-receive-hook.sh
index 6da6f597a50..98b0e812082 100755
--- a/t/t5411-proc-receive-hook.sh
+++ b/t/t5411-proc-receive-hook.sh
@@ -5,16 +5,11 @@

 test_description='Test proc-receive hook'

-GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

 . ./test-lib.sh

-test_have_prereq PREPARE_FOR_MAIN_BRANCH || {
-	test_skip="In transit for the default branch name 'main'"
-	test_done
-}
-
 . "$TEST_DIRECTORY"/t5411/common-functions.sh

 setup_upstream_and_workbench () {
-- snap --

would be much more understandable?

If so, I agree, and I will gladly send off the next iteration with that
change.

If I misunderstood, can I please ask you to give it another try to explain
it to me?

Thanks,
Dscho
Junio C Hamano Oct. 30, 2020, 5:06 p.m. UTC | #4
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Do you mean that this patch, squashed into 1/4:
> ...
> would be much more understandable?

Yes, that was what I meant.  

We could have a "test_skip='under construction'" without any
PREPARE_FOR_MAIN_BRANCH in 1/4 and then replace that with the
endgame state you already had in 4/4, alternatively, which might
already be enough explanation for a short transition period that
lasts just few patches ;-).

> If so, I agree, and I will gladly send off the next iteration with that
> change.
>
> If I misunderstood, can I please ask you to give it another try to explain
> it to me?

No, you understood what I meant perfectly.

Thanks.
diff mbox series

Patch

diff --git a/t/t5411-proc-receive-hook.sh b/t/t5411-proc-receive-hook.sh
index 746487286f..06bbb02ed2 100755
--- a/t/t5411-proc-receive-hook.sh
+++ b/t/t5411-proc-receive-hook.sh
@@ -7,11 +7,16 @@  test_description='Test proc-receive hook'
 
 . ./test-lib.sh
 
+test_have_prereq PREPARE_FOR_MAIN_BRANCH || {
+	test_skip="In transit for the default branch name 'main'"
+	test_done
+}
+
 . "$TEST_DIRECTORY"/t5411/common-functions.sh
 
 setup_upstream_and_workbench () {
-	# Refs of upstream : master(A)
-	# Refs of workbench: master(A)  tags/v123
+	# Refs of upstream : main(A)
+	# Refs of workbench: main(A)  tags/v123
 	test_expect_success "setup upstream and workbench" '
 		rm -rf upstream.git &&
 		rm -rf workbench &&
@@ -25,10 +30,10 @@  setup_upstream_and_workbench () {
 			git config core.abbrev 7 &&
 			git tag -m "v123" v123 $A &&
 			git remote add origin ../upstream.git &&
-			git push origin master &&
-			git update-ref refs/heads/master $A $B &&
+			git push origin main &&
+			git update-ref refs/heads/main $A $B &&
 			git -C ../upstream.git update-ref \
-				refs/heads/master $A $B
+				refs/heads/main $A $B
 		) &&
 		TAG=$(git -C workbench rev-parse v123) &&
 
@@ -99,8 +104,8 @@  start_httpd
 # Re-initialize the upstream repository and local workbench.
 setup_upstream_and_workbench
 
-# Refs of upstream : master(A)
-# Refs of workbench: master(A)  tags/v123
+# Refs of upstream : main(A)
+# Refs of workbench: main(A)  tags/v123
 test_expect_success "setup for HTTP protocol" '
 	git -C upstream.git config http.receivepack true &&
 	upstream="$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" &&