git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Toon Claes <toon@iotcl.com>,
	Christian Couder <christian.couder@gmail.com>,
	Justin Tobler <jltobler@gmail.com>
Subject: [PATCH v3 3/6] t1302: make tests more robust with new extensions
Date: Wed, 24 Jan 2024 09:45:13 +0100	[thread overview]
Message-ID: <ec90320ff1d5c0a6e5657ef77096c90d816f0513.1706085756.git.ps@pks.im> (raw)
In-Reply-To: <cover.1706085756.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 2977 bytes --]

In t1302 we exercise logic around "core.repositoryFormatVersion" and
extensions. These tests are not particularly robust against extensions
like the newly introduced "refStorage" extension as we tend to clobber
the repository's config file. We thus overwrite any extensions that were
set, which may render the repository inaccessible in case it has to be
accessed with a non-default ref storage.

Refactor the tests to be more robust:

  - Check the DEFAULT_REPO_FORMAT prereq to determine the expected
    repository format version. This helps to ensure that we only need to
    update the prereq in a central place when new extensions are added.
    Furthermore, this allows us to stop seeding the now-unneeded object
    ID cache that was only used to figure out the repository version.

  - Use a separate repository to rewrite ".git/config" to test
    combinations of the repository format version and extensions. This
    ensures that we don't break the main test repository. While we could
    rewrite these tests to not overwrite preexisting extensions, it
    feels cleaner like this so that we can test extensions standalone
    without interference from the environment.

  - Do not rewrite ".git/config" when exercising the "preciousObjects"
    extension.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t1302-repo-version.sh | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
index 179474fa65..42caa0d297 100755
--- a/t/t1302-repo-version.sh
+++ b/t/t1302-repo-version.sh
@@ -9,10 +9,6 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-	test_oid_cache <<-\EOF &&
-	version sha1:0
-	version sha256:1
-	EOF
 	cat >test.patch <<-\EOF &&
 	diff --git a/test.txt b/test.txt
 	new file mode 100644
@@ -28,7 +24,12 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'gitdir selection on normal repos' '
-	test_oid version >expect &&
+	if test_have_prereq DEFAULT_REPO_FORMAT
+	then
+		echo 0
+	else
+		echo 1
+	fi >expect &&
 	git config core.repositoryformatversion >actual &&
 	git -C test config core.repositoryformatversion >actual2 &&
 	test_cmp expect actual &&
@@ -79,8 +80,13 @@ mkconfig () {
 
 while read outcome version extensions; do
 	test_expect_success "$outcome version=$version $extensions" "
-		mkconfig $version $extensions >.git/config &&
-		check_${outcome}
+		test_when_finished 'rm -rf extensions' &&
+		git init extensions &&
+		(
+			cd extensions &&
+			mkconfig $version $extensions >.git/config &&
+			check_${outcome}
+		)
 	"
 done <<\EOF
 allow 0
@@ -94,7 +100,8 @@ allow 1 noop-v1
 EOF
 
 test_expect_success 'precious-objects allowed' '
-	mkconfig 1 preciousObjects >.git/config &&
+	git config core.repositoryFormatVersion 1 &&
+	git config extensions.preciousObjects 1 &&
 	check_allow
 '
 
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2024-01-24  8:45 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 12:17 [PATCH 0/6] t: mark "files"-backend specific tests Patrick Steinhardt
2024-01-09 12:17 ` [PATCH 1/6] t1300: mark tests to require default repo format Patrick Steinhardt
2024-01-09 18:41   ` Taylor Blau
2024-01-10  7:15     ` Patrick Steinhardt
2024-01-09 19:35   ` Eric Sunshine
2024-01-10  7:17     ` Patrick Steinhardt
2024-01-09 12:17 ` [PATCH 2/6] t1301: mark test for `core.sharedRepository` as reffiles specific Patrick Steinhardt
2024-01-09 12:17 ` [PATCH 3/6] t1302: make tests more robust with new extensions Patrick Steinhardt
2024-01-09 18:43   ` Taylor Blau
2024-01-09 12:17 ` [PATCH 4/6] t1419: mark test suite as files-backend specific Patrick Steinhardt
2024-01-09 19:40   ` Eric Sunshine
2024-01-10  7:30     ` Patrick Steinhardt
2024-01-10 16:27       ` Junio C Hamano
2024-01-11  5:05         ` Patrick Steinhardt
2024-01-09 12:17 ` [PATCH 5/6] t5526: break test submodule differently Patrick Steinhardt
2024-01-09 19:23   ` Eric Sunshine
2024-01-10  7:41     ` Patrick Steinhardt
2024-01-09 12:17 ` [PATCH 6/6] t: mark tests regarding git-pack-refs(1) to be backend specific Patrick Steinhardt
2024-01-10  9:01 ` [PATCH v2 0/6] t: mark "files"-backend specific tests Patrick Steinhardt
2024-01-10  9:01   ` [PATCH v2 1/6] t1300: make tests more robust with non-default ref backends Patrick Steinhardt
2024-01-23 13:41     ` Toon Claes
2024-01-23 15:22       ` Patrick Steinhardt
2024-01-23 16:43         ` Justin Tobler
2024-01-23 16:15     ` Christian Couder
2024-01-24  8:52       ` Patrick Steinhardt
2024-01-29 10:32         ` Christian Couder
2024-01-29 10:49           ` Patrick Steinhardt
2024-01-10  9:01   ` [PATCH v2 2/6] t1301: mark test for `core.sharedRepository` as reffiles specific Patrick Steinhardt
2024-01-10  9:01   ` [PATCH v2 3/6] t1302: make tests more robust with new extensions Patrick Steinhardt
2024-01-23 14:08     ` Toon Claes
2024-01-23 15:18       ` Patrick Steinhardt
2024-01-23 16:15     ` Christian Couder
2024-01-24  8:52       ` Patrick Steinhardt
2024-01-10  9:01   ` [PATCH v2 4/6] t1419: mark test suite as files-backend specific Patrick Steinhardt
2024-01-10  9:01   ` [PATCH v2 5/6] t5526: break test submodule differently Patrick Steinhardt
2024-01-10  9:01   ` [PATCH v2 6/6] t: mark tests regarding git-pack-refs(1) to be backend specific Patrick Steinhardt
2024-01-23 16:20   ` [PATCH v2 0/6] t: mark "files"-backend specific tests Christian Couder
2024-01-24  8:45 ` [PATCH v3 " Patrick Steinhardt
2024-01-24  8:45   ` [PATCH v3 1/6] t1300: make tests more robust with non-default ref backends Patrick Steinhardt
2024-01-24  8:45   ` [PATCH v3 2/6] t1301: mark test for `core.sharedRepository` as reffiles specific Patrick Steinhardt
2024-01-24  8:45   ` Patrick Steinhardt [this message]
2024-01-24  8:45   ` [PATCH v3 4/6] t1419: mark test suite as files-backend specific Patrick Steinhardt
2024-01-24  8:45   ` [PATCH v3 5/6] t5526: break test submodule differently Patrick Steinhardt
2024-01-24  8:45   ` [PATCH v3 6/6] t: mark tests regarding git-pack-refs(1) to be backend specific Patrick Steinhardt
2024-01-29 11:07 ` [PATCH v4 0/6] t: mark "files"-backend specific tests Patrick Steinhardt
2024-01-29 11:07   ` [PATCH v4 1/6] t1300: make tests more robust with non-default ref backends Patrick Steinhardt
2024-01-29 12:00     ` Christian Couder
2024-01-29 11:07   ` [PATCH v4 2/6] t1301: mark test for `core.sharedRepository` as reffiles specific Patrick Steinhardt
2024-01-29 11:07   ` [PATCH v4 3/6] t1302: make tests more robust with new extensions Patrick Steinhardt
2024-01-29 11:07   ` [PATCH v4 4/6] t1419: mark test suite as files-backend specific Patrick Steinhardt
2024-01-29 11:07   ` [PATCH v4 5/6] t5526: break test submodule differently Patrick Steinhardt
2024-01-29 11:07   ` [PATCH v4 6/6] t: mark tests regarding git-pack-refs(1) to be backend specific Patrick Steinhardt
2024-01-29 12:03   ` [PATCH v4 0/6] t: mark "files"-backend specific tests Christian Couder
2024-01-29 20:38     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec90320ff1d5c0a6e5657ef77096c90d816f0513.1706085756.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jltobler@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=sunshine@sunshineco.com \
    --cc=toon@iotcl.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).