Use flag instead of build tag to run integration tests

This commit is contained in:
Alexander Neumann 2015-06-05 22:33:39 +02:00
parent 7c107acf0b
commit 12677b4f8a
5 changed files with 17 additions and 12 deletions

View File

@ -50,15 +50,15 @@ gox: .gopath $(SOURCE)
test-integration: .gopath
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
-tags integration \
./backend \
-cover -covermode=count -coverprofile=integration-sftp.cov \
-test.integration \
-test.sftppath=$(SFTP_PATH)
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
-tags integration \
./cmd/restic \
-cover -covermode=count -coverprofile=integration.cov \
-test.integration \
-test.datafile=$(PWD)/testsuite/fake-data.tar.gz
all.cov: .gopath $(SOURCE) test-integration

View File

@ -1,5 +1,3 @@
// +build integration
package backend_test
import (
@ -37,6 +35,10 @@ func teardownSFTPBackend(t *testing.T, b *sftp.SFTP) {
}
func TestSFTPBackend(t *testing.T) {
if !*RunIntegrationTest {
t.Skip("integration tests disabled, use `-test.integration` to enable")
}
if *sftpPath == "" {
t.Skipf("sftppath not set, skipping TestSFTPBackend")
}

View File

@ -1,5 +1,3 @@
// +build integration
package main
import (

View File

@ -1,5 +1,3 @@
// +build integration
package main
import (
@ -119,8 +117,12 @@ func cmdFsck(t testing.TB) {
}
func TestBackup(t *testing.T) {
if !*RunIntegrationTest {
t.Skip("integration tests disabled, use `-test.integration` to enable")
}
if *TestDataFile == "" {
t.Fatal("no data tar file specified, use flag '-test.datafile'")
t.Fatal("no data tar file specified, use flag `-test.datafile`")
}
tempdir := setupTempdir(t)

View File

@ -12,9 +12,12 @@ import (
"github.com/restic/restic/repository"
)
var TestPassword = flag.String("test.password", "geheim", `use this password for repositories created during tests (default: "geheim")`)
var TestCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)")
var TestTempDir = flag.String("test.tempdir", "", "use this directory for temporary storage (default: system temp dir)")
var (
TestPassword = flag.String("test.password", "geheim", `use this password for repositories created during tests (default: "geheim")`)
TestCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)")
TestTempDir = flag.String("test.tempdir", "", "use this directory for temporary storage (default: system temp dir)")
RunIntegrationTest = flag.Bool("test.integration", false, "run integration tests (default: false)")
)
func SetupRepo(t testing.TB) *repository.Repository {
tempdir, err := ioutil.TempDir(*TestTempDir, "restic-test-")