diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-08-23 08:08:32 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-08-23 08:08:32 +0300 |
commit | e1ef45ca36514b3901a818643d86fe40231513af (patch) | |
tree | 7d76f579a408c59c0f582dc3389cbf230661ebac | |
parent | b412fb9616dbcb063b49051789ce212f6ccc6269 (diff) |
gittest: Dynamically detect whether to skip SHA256 tests
We are now in a state where all functionality except for backups work
with the SHA256 object format. This means we can also get rid of the
build tag that we used for our tests in favor of dynamically skipping
over tests when we see that the object format is unsupported.
Introduce a new function `SkipWithSHA256()` and convert all tests using
the `!gitaly_test_sha256` build tag to use it instead.
-rw-r--r-- | cmd/gitaly-backup/restore_test.go | 6 | ||||
-rw-r--r-- | cmd/gitaly-git2go/rebase_test.go | 8 | ||||
-rw-r--r-- | cmd/gitaly-git2go/testhelper_test.go | 2 | ||||
-rw-r--r-- | internal/backup/backup_test.go | 16 | ||||
-rw-r--r-- | internal/backup/locator_test.go | 6 | ||||
-rw-r--r-- | internal/backup/server_side_test.go | 8 | ||||
-rw-r--r-- | internal/git/gittest/object_hash.go | 10 | ||||
-rw-r--r-- | internal/gitaly/service/repository/restore_repository_test.go | 4 |
8 files changed, 48 insertions, 12 deletions
diff --git a/cmd/gitaly-backup/restore_test.go b/cmd/gitaly-backup/restore_test.go index 386e79d68..7b327f3eb 100644 --- a/cmd/gitaly-backup/restore_test.go +++ b/cmd/gitaly-backup/restore_test.go @@ -1,5 +1,3 @@ -//go:build !gitaly_test_sha256 - package main import ( @@ -25,6 +23,8 @@ import ( ) func TestRestoreSubcommand(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() ctx := testhelper.Context(t) @@ -99,6 +99,8 @@ func TestRestoreSubcommand(t *testing.T) { } func TestRestoreSubcommand_serverSide(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() ctx := testhelper.Context(t) diff --git a/cmd/gitaly-git2go/rebase_test.go b/cmd/gitaly-git2go/rebase_test.go index 6d4a76b99..3a0d6b8f5 100644 --- a/cmd/gitaly-git2go/rebase_test.go +++ b/cmd/gitaly-git2go/rebase_test.go @@ -1,4 +1,4 @@ -//go:build static && system_libgit2 && !gitaly_test_sha256 +//go:build static && system_libgit2 package main @@ -20,6 +20,8 @@ import ( var masterRevision = "1e292f8fedd741b75372e19097c76d327140c312" func TestRebase_validation(t *testing.T) { + gittest.SkipWithSHA256(t) + ctx := testhelper.Context(t) cfg := testcfg.Build(t) @@ -87,6 +89,8 @@ func TestRebase_validation(t *testing.T) { } func TestRebase_rebase(t *testing.T) { + gittest.SkipWithSHA256(t) + testcases := []struct { desc string branch string @@ -248,6 +252,8 @@ func TestRebase_rebase(t *testing.T) { } func TestRebase_skipEmptyCommit(t *testing.T) { + gittest.SkipWithSHA256(t) + ctx := testhelper.Context(t) cfg := testcfg.Build(t) diff --git a/cmd/gitaly-git2go/testhelper_test.go b/cmd/gitaly-git2go/testhelper_test.go index 765b4470e..f798dc417 100644 --- a/cmd/gitaly-git2go/testhelper_test.go +++ b/cmd/gitaly-git2go/testhelper_test.go @@ -1,4 +1,4 @@ -//go:build static && system_libgit2 && !gitaly_test_sha256 +//go:build static && system_libgit2 package main diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index f437ce6a5..4dca937a0 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -1,5 +1,3 @@ -//go:build !gitaly_test_sha256 - package backup_test import ( @@ -31,6 +29,8 @@ import ( ) func TestManager_RemoveAllRepositories(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() cfg := testcfg.Build(t) @@ -61,6 +61,8 @@ func TestManager_RemoveAllRepositories(t *testing.T) { } func TestManager_Create(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() const backupID = "abc123" @@ -230,6 +232,8 @@ func TestManager_Create(t *testing.T) { } func TestManager_Create_incremental(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() const backupID = "abc123" @@ -377,6 +381,8 @@ func TestManager_Create_incremental(t *testing.T) { } func TestManager_Restore_latest(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() cfg := testcfg.Build(t) @@ -716,6 +722,8 @@ func TestManager_Restore_latest(t *testing.T) { } func TestManager_Restore_specific(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() const backupID = "abc123" @@ -917,6 +925,8 @@ func TestManager_Restore_specific(t *testing.T) { } func TestManager_CreateRestore_contextServerInfo(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() cfg := testcfg.Build(t) @@ -954,6 +964,8 @@ func TestManager_CreateRestore_contextServerInfo(t *testing.T) { } func TestResolveLocator(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() for _, tc := range []struct { diff --git a/internal/backup/locator_test.go b/internal/backup/locator_test.go index 01534d368..22767f4d4 100644 --- a/internal/backup/locator_test.go +++ b/internal/backup/locator_test.go @@ -1,5 +1,3 @@ -//go:build !gitaly_test_sha256 - package backup import ( @@ -19,6 +17,8 @@ import ( ) func TestLegacyLocator(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() ctx := testhelper.Context(t) @@ -68,6 +68,8 @@ func TestLegacyLocator(t *testing.T) { } func TestPointerLocator(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() const backupID = "abc123" diff --git a/internal/backup/server_side_test.go b/internal/backup/server_side_test.go index 3329c8a78..8c49c3046 100644 --- a/internal/backup/server_side_test.go +++ b/internal/backup/server_side_test.go @@ -1,5 +1,3 @@ -//go:build !gitaly_test_sha256 - package backup_test import ( @@ -23,6 +21,8 @@ import ( ) func TestServerSideAdapter_Create(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() ctx := testhelper.Context(t) @@ -131,6 +131,8 @@ func TestServerSideAdapter_Create(t *testing.T) { } func TestServerSideAdapter_Restore(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() ctx := testhelper.Context(t) @@ -240,6 +242,8 @@ func TestServerSideAdapter_Restore(t *testing.T) { } func TestServerSideAdapter_RemoveAllRepositories(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() backupRoot := testhelper.TempDir(t) diff --git a/internal/git/gittest/object_hash.go b/internal/git/gittest/object_hash.go new file mode 100644 index 000000000..4a1e4079a --- /dev/null +++ b/internal/git/gittest/object_hash.go @@ -0,0 +1,10 @@ +package gittest + +import "testing" + +// SkipWithSHA256 skips the test in case the default object hash is SHA256. +func SkipWithSHA256(tb testing.TB) { + if DefaultObjectHash.Format == "sha256" { + tb.Skip("test is not compatible with SHA256") + } +} diff --git a/internal/gitaly/service/repository/restore_repository_test.go b/internal/gitaly/service/repository/restore_repository_test.go index 2da64b841..5d5fbfbb0 100644 --- a/internal/gitaly/service/repository/restore_repository_test.go +++ b/internal/gitaly/service/repository/restore_repository_test.go @@ -1,5 +1,3 @@ -//go:build !gitaly_test_sha256 - package repository import ( @@ -18,6 +16,8 @@ import ( ) func TestRestoreRepository(t *testing.T) { + gittest.SkipWithSHA256(t) + t.Parallel() ctx := testhelper.Context(t) |