Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-08-18 13:51:40 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-08-23 08:08:33 +0300
commitdbf4ad6f9804cc8a3ddb241a1a5ff1e21b2400d9 (patch)
treed3772d2b75f6511cc3fe679dfb0596c32cfa1dcf
parentd46ef1eaa65d7ddd0b56a17bdbae75120c345c3d (diff)
gittest: Detect default object format via environment variable
Right now Gitaly still has two different build variants for its tests, one for each of the supported object formats. This also means that we have to essentially build the code base twice, doubling the amount of data we need to put into our caches and increasing build times overall. Drop the build flag in favor of an environment variable that modifies the default object format.
-rw-r--r--Makefile3
-rw-r--r--internal/git/gittest/object_hash.go16
-rw-r--r--internal/git/gittest/sha1.go8
-rw-r--r--internal/git/gittest/sha256.go10
4 files changed, 16 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 4333c7a41..d24900602 100644
--- a/Makefile
+++ b/Makefile
@@ -345,8 +345,7 @@ endif
## Enable testing with the SHA256 object format.
TEST_WITH_SHA256 ?=
ifdef TEST_WITH_SHA256
- SERVER_BUILD_TAGS := ${SERVER_BUILD_TAGS},gitaly_test_sha256
- GIT2GO_BUILD_TAGS := ${GIT2GO_BUILD_TAGS},gitaly_test_sha256
+export GITALY_TEST_WITH_SHA256 = YesPlease
endif
## Enable generating test coverage.
diff --git a/internal/git/gittest/object_hash.go b/internal/git/gittest/object_hash.go
index 4a1e4079a..ed61c3df9 100644
--- a/internal/git/gittest/object_hash.go
+++ b/internal/git/gittest/object_hash.go
@@ -1,6 +1,20 @@
package gittest
-import "testing"
+import (
+ "os"
+ "testing"
+
+ "gitlab.com/gitlab-org/gitaly/v16/internal/git"
+)
+
+// DefaultObjectHash is the default object hash used for running tests.
+var DefaultObjectHash = func() git.ObjectHash {
+ if _, enabled := os.LookupEnv("GITALY_TEST_WITH_SHA256"); enabled {
+ return git.ObjectHashSHA256
+ }
+
+ return git.ObjectHashSHA1
+}()
// SkipWithSHA256 skips the test in case the default object hash is SHA256.
func SkipWithSHA256(tb testing.TB) {
diff --git a/internal/git/gittest/sha1.go b/internal/git/gittest/sha1.go
deleted file mode 100644
index 76ae7bd3e..000000000
--- a/internal/git/gittest/sha1.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build !gitaly_test_sha256
-
-package gittest
-
-import "gitlab.com/gitlab-org/gitaly/v16/internal/git"
-
-// DefaultObjectHash is the default hash used for running tests.
-var DefaultObjectHash = git.ObjectHashSHA1
diff --git a/internal/git/gittest/sha256.go b/internal/git/gittest/sha256.go
deleted file mode 100644
index f2ac3324c..000000000
--- a/internal/git/gittest/sha256.go
+++ /dev/null
@@ -1,10 +0,0 @@
-//go:build gitaly_test_sha256
-
-package gittest
-
-import (
- "gitlab.com/gitlab-org/gitaly/v16/internal/git"
-)
-
-// DefaultObjectHash is the default hash used for running tests.
-var DefaultObjectHash = git.ObjectHashSHA256