mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
Merge pull request #2582 from greatroar/no-go1.9
Remove Go 1.9 compatibility code
This commit is contained in:
commit
f165048172
@ -14,7 +14,6 @@ import (
|
|||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
"github.com/restic/restic/internal/fs"
|
"github.com/restic/restic/internal/fs"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/restic/restic/internal/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSnapshot creates a new snapshot of path.
|
// 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,
|
// TestCreateFiles creates a directory structure described by dir at target,
|
||||||
// which must already exist. On Windows, symlinks aren't created.
|
// which must already exist. On Windows, symlinks aren't created.
|
||||||
func TestCreateFiles(t testing.TB, target string, dir TestDir) {
|
func TestCreateFiles(t testing.TB, target string, dir TestDir) {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
for name, item := range dir {
|
for name, item := range dir {
|
||||||
targetPath := filepath.Join(target, name)
|
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
|
// TestWalkFiles runs fn for each file/directory in dir, the filename will be
|
||||||
// constructed with target as the prefix. Symlinks on Windows are ignored.
|
// constructed with target as the prefix. Symlinks on Windows are ignored.
|
||||||
func TestWalkFiles(t testing.TB, target string, dir TestDir, fn TestWalkFunc) {
|
func TestWalkFiles(t testing.TB, target string, dir TestDir, fn TestWalkFunc) {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
for name, item := range dir {
|
for name, item := range dir {
|
||||||
targetPath := filepath.Join(target, name)
|
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
|
// TestEnsureFiles tests if the directory structure at target is the same as
|
||||||
// described in dir.
|
// described in dir.
|
||||||
func TestEnsureFiles(t testing.TB, target string, dir TestDir) {
|
func TestEnsureFiles(t testing.TB, target string, dir TestDir) {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
pathsChecked := make(map[string]struct{})
|
pathsChecked := make(map[string]struct{})
|
||||||
|
|
||||||
// first, test that all items are there
|
// 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,
|
// TestEnsureTree checks that the tree ID in the repo matches dir. On Windows,
|
||||||
// Symlinks are ignored.
|
// Symlinks are ignored.
|
||||||
func TestEnsureTree(ctx context.Context, t testing.TB, prefix string, repo restic.Repository, treeID restic.ID, dir TestDir) {
|
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)
|
tree, err := repo.LoadTree(ctx, treeID)
|
||||||
if err != nil {
|
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
|
// TestEnsureSnapshot tests if the snapshot in the repo has exactly the same
|
||||||
// structure as dir. On Windows, Symlinks are ignored.
|
// structure as dir. On Windows, Symlinks are ignored.
|
||||||
func TestEnsureSnapshot(t testing.TB, repo restic.Repository, snapshotID restic.ID, dir TestDir) {
|
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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsRegularFile returns true if fi belongs to a normal file. If fi is nil,
|
// 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.
|
// TestChdir changes the current directory to dest, the function back returns to the previous directory.
|
||||||
func TestChdir(t testing.TB, dest string) (back func()) {
|
func TestChdir(t testing.TB, dest string) (back func()) {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
|
|
||||||
prev, err := os.Getwd()
|
prev, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -34,7 +32,7 @@ func TestChdir(t testing.TB, dest string) (back func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
t.Logf("chdir back to %v", prev)
|
t.Logf("chdir back to %v", prev)
|
||||||
err = os.Chdir(prev)
|
err = os.Chdir(prev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -42,7 +42,7 @@ const testChunkerPol = chunker.Pol(0x3DA3358B4DC173)
|
|||||||
// password. If be is nil, an in-memory backend is used. A constant polynomial
|
// password. If be is nil, an in-memory backend is used. A constant polynomial
|
||||||
// is used for the chunker and low-security test parameters.
|
// is used for the chunker and low-security test parameters.
|
||||||
func TestRepositoryWithBackend(t testing.TB, be restic.Backend) (r restic.Repository, cleanup func()) {
|
func TestRepositoryWithBackend(t testing.TB, be restic.Backend) (r restic.Repository, cleanup func()) {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
TestUseLowSecurityKDFParameters(t)
|
TestUseLowSecurityKDFParameters(t)
|
||||||
restic.TestDisableCheckPolynomial(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
|
// 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.
|
// instead. The directory is not removed, but left there for inspection.
|
||||||
func TestRepository(t testing.TB) (r restic.Repository, cleanup func()) {
|
func TestRepository(t testing.TB) (r restic.Repository, cleanup func()) {
|
||||||
test.Helper(t).Helper()
|
t.Helper()
|
||||||
dir := os.Getenv("RESTIC_TEST_REPO")
|
dir := os.Getenv("RESTIC_TEST_REPO")
|
||||||
if dir != "" {
|
if dir != "" {
|
||||||
_, err := os.Stat(dir)
|
_, err := os.Stat(dir)
|
||||||
|
@ -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
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user