Add workaround for testing/cgo issue (#469)

Test code in `lib` package requires cgo, but cgo is not allowed in `*_test.go` files, so we import a lot of testing-related code into a library which also has a lot of side-effects. This fix adds a build tag `e2e_test` as a workaround.
This commit is contained in:
Adam Babik 2017-11-22 14:06:14 +01:00 committed by Ivan Daniluk
parent 001a902407
commit 74d3e5e625
4 changed files with 18 additions and 3 deletions

View File

@ -115,7 +115,8 @@ test-e2e: ##@tests Run e2e tests
go test -timeout 20m ./e2e/rpc/... -network=$(networkid)
go test -timeout 20m ./e2e/whisper/... -network=$(networkid)
go test -timeout 10m ./e2e/transactions/... -network=$(networkid)
go test -timeout 40m ./lib -network=$(networkid)
# e2e_test tag is required to include some files from ./lib without _test suffix
go test -timeout 40m -tags e2e_test ./lib -network=$(networkid)
ci: lint mock-install mock test-unit test-e2e ##@tests Run all linters and tests at once

View File

@ -1,3 +1,9 @@
// +build e2e_test
// Tests in `./lib` package will run only when `e2e_test` build tag is provided.
// It's required to prevent some files from being included in the binary.
// Check out `lib/utils.go` for more details.
package main
import (

View File

@ -9,5 +9,4 @@ var statusAPI = api.NewStatusAPI()
// without main it produces cryptic errors.
// TODO(divan): investigate the cause of the errors
// and change this package to be a library if possible.
func main() {
}
func main() {}

View File

@ -1,3 +1,12 @@
// +build e2e_test
// This is a file with e2e tests for C bindings written in library.go.
// As a CGO file, it can't have `_test.go` suffix as it's not allowed by Go.
// At the same time, we don't want this file to be included in the binaries.
// This is why `e2e_test` tag was introduced. Without it, this file is excluded
// from the build. Providing this tag will include this file into the build
// and that's what is done while running e2e tests for `lib/` package.
package main
import "C"