From 4f6fd9fb986c2cc35db9ef3d81b618f280c5be65 Mon Sep 17 00:00:00 2001 From: greatroar <@> Date: Mon, 17 Feb 2020 13:07:55 +0100 Subject: [PATCH] Remove remnant of Go 1.9 compatibility code from tests --- internal/archiver/testing.go | 11 +++++------ internal/fs/helpers.go | 6 ++---- internal/repository/testing.go | 4 ++-- internal/test/helper.go | 13 ------------- 4 files changed, 9 insertions(+), 25 deletions(-) delete mode 100644 internal/test/helper.go diff --git a/internal/archiver/testing.go b/internal/archiver/testing.go index bdb122d69..790e94950 100644 --- a/internal/archiver/testing.go +++ b/internal/archiver/testing.go @@ -14,7 +14,6 @@ import ( "github.com/restic/restic/internal/debug" "github.com/restic/restic/internal/fs" "github.com/restic/restic/internal/restic" - "github.com/restic/restic/internal/test" ) // TestSnapshot creates a new snapshot of path. @@ -63,7 +62,7 @@ func (s TestSymlink) String() string { // TestCreateFiles creates a directory structure described by dir at target, // which must already exist. On Windows, symlinks aren't created. func TestCreateFiles(t testing.TB, target string, dir TestDir) { - test.Helper(t).Helper() + t.Helper() for name, item := range dir { targetPath := filepath.Join(target, name) @@ -100,7 +99,7 @@ type TestWalkFunc func(path string, item interface{}) error // TestWalkFiles runs fn for each file/directory in dir, the filename will be // constructed with target as the prefix. Symlinks on Windows are ignored. func TestWalkFiles(t testing.TB, target string, dir TestDir, fn TestWalkFunc) { - test.Helper(t).Helper() + t.Helper() for name, item := range dir { targetPath := filepath.Join(target, name) @@ -130,7 +129,7 @@ func fixpath(item string) string { // TestEnsureFiles tests if the directory structure at target is the same as // described in dir. func TestEnsureFiles(t testing.TB, target string, dir TestDir) { - test.Helper(t).Helper() + t.Helper() pathsChecked := make(map[string]struct{}) // first, test that all items are there @@ -248,7 +247,7 @@ func TestEnsureFileContent(ctx context.Context, t testing.TB, repo restic.Reposi // TestEnsureTree checks that the tree ID in the repo matches dir. On Windows, // Symlinks are ignored. func TestEnsureTree(ctx context.Context, t testing.TB, prefix string, repo restic.Repository, treeID restic.ID, dir TestDir) { - test.Helper(t).Helper() + t.Helper() tree, err := repo.LoadTree(ctx, treeID) if err != nil { @@ -324,7 +323,7 @@ func TestEnsureTree(ctx context.Context, t testing.TB, prefix string, repo resti // TestEnsureSnapshot tests if the snapshot in the repo has exactly the same // structure as dir. On Windows, Symlinks are ignored. func TestEnsureSnapshot(t testing.TB, repo restic.Repository, snapshotID restic.ID, dir TestDir) { - test.Helper(t).Helper() + t.Helper() ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/internal/fs/helpers.go b/internal/fs/helpers.go index 768cc975b..787fe485a 100644 --- a/internal/fs/helpers.go +++ b/internal/fs/helpers.go @@ -4,8 +4,6 @@ import ( "io/ioutil" "os" "testing" - - "github.com/restic/restic/internal/test" ) // IsRegularFile returns true if fi belongs to a normal file. If fi is nil, @@ -20,7 +18,7 @@ func IsRegularFile(fi os.FileInfo) bool { // TestChdir changes the current directory to dest, the function back returns to the previous directory. func TestChdir(t testing.TB, dest string) (back func()) { - test.Helper(t).Helper() + t.Helper() prev, err := os.Getwd() if err != nil { @@ -34,7 +32,7 @@ func TestChdir(t testing.TB, dest string) (back func()) { } return func() { - test.Helper(t).Helper() + t.Helper() t.Logf("chdir back to %v", prev) err = os.Chdir(prev) if err != nil { diff --git a/internal/repository/testing.go b/internal/repository/testing.go index ad8c7a2a0..e070cdc8a 100644 --- a/internal/repository/testing.go +++ b/internal/repository/testing.go @@ -42,7 +42,7 @@ const testChunkerPol = chunker.Pol(0x3DA3358B4DC173) // password. If be is nil, an in-memory backend is used. A constant polynomial // is used for the chunker and low-security test parameters. func TestRepositoryWithBackend(t testing.TB, be restic.Backend) (r restic.Repository, cleanup func()) { - test.Helper(t).Helper() + t.Helper() TestUseLowSecurityKDFParameters(t) restic.TestDisableCheckPolynomial(t) @@ -71,7 +71,7 @@ func TestRepositoryWithBackend(t testing.TB, be restic.Backend) (r restic.Reposi // a non-existing directory, a local backend is created there and this is used // instead. The directory is not removed, but left there for inspection. func TestRepository(t testing.TB) (r restic.Repository, cleanup func()) { - test.Helper(t).Helper() + t.Helper() dir := os.Getenv("RESTIC_TEST_REPO") if dir != "" { _, err := os.Stat(dir) diff --git a/internal/test/helper.go b/internal/test/helper.go deleted file mode 100644 index c5fe3188c..000000000 --- a/internal/test/helper.go +++ /dev/null @@ -1,13 +0,0 @@ -package test - -import "testing" - -// Helperer marks the current function as a test helper. -type Helperer interface { - Helper() -} - -// Helper returns a function that marks the current function as a helper function. -func Helper(t testing.TB) Helperer { - return t -}