Subject: [PATCH v2 28/27] tests: run tests omitted by PREPARE_FOR_MAIN_BRANCH

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Wed, 18 Nov 2020 12:48:34 +0100

Reinstate the test coverage lost due to PREPARE_FOR_MAIN_BRANCH. The
remaining impact of that prerequisite was mainly missing coverage from
submodule fetches being lost[1], e.g. impacting my in-flight
ab/retire-parse-remote. Now the prerequisite is effectively a
noop. This goes on top of [2].

I'm not removing the PREPARE_FOR_MAIN_BRANCH prerequisite to keep this
change small, instead it's now effectively a noop. It can be removed
in some later change.

The only remaining occurrences in t5526-fetch-submodules.sh can be
removed without breakage with:

    perl -pi -e 's/PREPARE_FOR_MAIN_BRANCH //g' t/t5526-fetch-submodules.sh

Which at this point leaves only the now-unused prerequisite
declaration in test-lib.sh.

The coverage in t9902-completion.sh was restored by partially
reverting[3]. After that we were left with one test in a mixed
state. It setup "master" but tested for "mai". Change it back to
"mas", pending a more complete refactoring of that test.

This change only conflicts between next..seen by clashing with Peter
Kaestle's in-flights submodule fix[4]. Fixing the resulting logic
error in t5526-fetch-submodules.sh is trivial, simply:

    - compare_refs_in_dir A origin/master B origin/master
    + compare_refs_in_dir A origin/main B origin/main

1. 66713e84e7 ("tests: prepare aligned mentions of the default branch name", 2020-10-23)
2. https://public-inbox.org/git/[email-masked]/
3. 8164360fc8 ("t9902: prepare a test for the upcoming default branch name", 2020-10-23)
4. https://public-inbox.org/git/[email-masked]/

Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
---

On Tue, Nov 17 2020, Johannes Schindelin via GitGitGadget wrote:
> To avoid even more conflicts with topics that did not even make it to seen 
> yet, this patch series specifically excludes t3404, t4013, t5310, t5526,
> t6300, t7064, t7817, t9902: in those test scripts, we will still use master 
> for the time being. Once the topics in question have settled, I will send
> the appropriate follow-up patches to adjust them to use main instead.

This is not a replacement for that subsequent cleanup, but seems like
a simple enough thing to have now to reinstate the missing test
coverage.

Perhaps there's some topics not in "seen" that you have in mind as
conflicting, but as noted above the conflict produced here with
in-flight in "seen" is trivial.

Seems worth having that sooner than later if Junio's willing juggle
that.

 t/t5526-fetch-submodules.sh | 6 +++---
 t/t9902-completion.sh       | 6 +++---
 t/test-lib.sh               | 9 +++------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index dd8e423d25..f45ba02b8a 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -481,7 +481,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "don't fetch submodule when newly re
 	test_i18ncmp expect.err actual.err &&
 	(
 		cd submodule &&
-		git checkout -q master
+		git checkout -q main
 	)
 '
 
@@ -663,9 +663,9 @@ test_expect_success 'fetch new submodule commits on-demand without .gitmodules e
 	git config -f .gitmodules --remove-section submodule.sub1 &&
 	git add .gitmodules &&
 	git commit -m "delete gitmodules file" &&
-	git checkout -B master &&
+	git checkout -B main &&
 	git -C downstream fetch &&
-	git -C downstream checkout origin/master &&
+	git -C downstream checkout origin/main &&
 
 	C=$(git -C submodule commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
 	git -C submodule update-ref refs/changes/7 $C &&
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 5c01c75d40..3696b85acb 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1055,13 +1055,13 @@ test_expect_success 'teardown after filtering matching refs' '
 	git -C otherrepo branch -D matching/branch-in-other
 '
 
-test_expect_success PREPARE_FOR_MAIN_BRANCH '__git_refs - for-each-ref format specifiers in prefix' '
+test_expect_success '__git_refs - for-each-ref format specifiers in prefix' '
 	cat >expected <<-EOF &&
 	evil-%%-%42-%(refname)..master
 	EOF
 	(
-		cur="evil-%%-%42-%(refname)..mai" &&
-		__git_refs "" "" "evil-%%-%42-%(refname).." mai >"$actual"
+		cur="evil-%%-%42-%(refname)..mas" &&
+		__git_refs "" "" "evil-%%-%42-%(refname).." mas >"$actual"
 	) &&
 	test_cmp expected "$actual"
 '
diff --git a/t/test-lib.sh b/t/test-lib.sh
index d39bdf04ce..ed489b2213 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -257,7 +257,7 @@ case "$TRASH_DIRECTORY" in
 esac
 
 case "$TEST_NUMBER" in
-3404|4013|5310|5526|6300|7064|7817|9902)
+3404|4013|5310|6300|7064|7817|9902)
 	# Avoid conflicts with patch series that are cooking at the same time
 	# as the patch series changing the default of `init.defaultBranch`.
 	GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
@@ -1725,12 +1725,9 @@ test_lazy_prereq REBASE_P '
 	test -z "$GIT_TEST_SKIP_REBASE_P"
 '
 
-# Special-purpose prereq for transitioning to a new default branch name:
-# Some tests need more than just a mindless (case-preserving) s/master/main/g
-# replacement. The non-trivial adjustments are guarded behind this
-# prerequisite, acting kind of as a feature flag
+# Obsolete, do not use, removed soon!
 test_lazy_prereq PREPARE_FOR_MAIN_BRANCH '
-	test "$GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME" = main
+	test "$TEST_NAME" = "t5526-fetch-submodules"
 '
 
 # Ensure that no test accidentally triggers a Git command
-- 
2.29.2.222.g5d2a92d10f8