Reputation: 197
I have a public golang project set up at http://github.com/NeilGarb/budget, with subpackages core and api. I keep the project in $GOPATH/src/github.com/NeilGarb/budget.
I would like to run core's ginkgo tests using Travis CI, but I'm using absolute imports in my test packages and Travis complains it can't find said packages.
For example, my test includes:
package user_test
import (
. "github.com/NeilGarb/budget/core"
)
Running ant works fine on my local machine, but when travis tries to run the test I get:
core-test:
[exec] Failed to compile core:
[exec]
[exec] can't load package: package github.com/NeilGarb/budget/core: cannot find package "github.com/NeilGarb/budget/core" in any of:
[exec] /home/travis/.gvm/gos/go1.2/src/pkg/github.com/NeilGarb/budget/core (from $GOROOT)
[exec] /home/travis/.gvm/pkgsets/go1.2/global/src/github.com/NeilGarb/budget/core (from $GOPATH)
[exec]
[exec] Ginkgo ran in 714.967041ms
[exec] Test Suite Failed
I've tried to use relative imports in my tests (i.e. . "../core"), which works, but then my coverage always shows 0% covered.
What to do? :(
Upvotes: 4
Views: 767
Reputation: 157
github.com/NeilGarb/budget/core
would need to vendor that package for the code to be available. See https://golang.org/cmd/go/#hdr-Vendor_Directories for documentation.
Upvotes: 0
Reputation: 197
I've solved this problem by constructing a symlink from $GOPATH/src/github.com/NeilGarb/budget to $TRAVIS_BUILD_DIR.
Upvotes: 2