diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f016b00..cc990e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,4 +89,4 @@ jobs: uses: actions/checkout@v1 - name: Run Third-Party Tests working-directory: ./tests/thirdparty - run: go test -v -pkgs packages.json + run: go test -pkgs packages.json diff --git a/tests/thirdparty/config.go b/tests/thirdparty/config.go index 113193b..d857a32 100644 --- a/tests/thirdparty/config.go +++ b/tests/thirdparty/config.go @@ -14,6 +14,7 @@ type Package struct { Version string `json:"version"` // git sha, tag or branch Generate [][]string `json:"generate"` // generate commands to run Dir string `json:"dir"` // working directory for generate commands + Test string `json:"test"` // test path relative to repo root (if empty defaults to ./...) } // Name returns the package name. @@ -26,6 +27,14 @@ func (p Package) CloneURL() string { return "https://" + p.ImportPath + ".git" } +// TestPath returns the paths to run "go test" on, relative to the repository root. +func (p Package) TestPath() string { + if p.Test == "" { + return "./..." + } + return p.Test +} + // LoadPackages loads a list of package configurations from JSON format. func LoadPackages(r io.Reader) ([]Package, error) { var pkgs []Package diff --git a/tests/thirdparty/config_test.go b/tests/thirdparty/config_test.go index 50faef0..88bd8a8 100644 --- a/tests/thirdparty/config_test.go +++ b/tests/thirdparty/config_test.go @@ -19,6 +19,18 @@ func TestPackageCloneURL(t *testing.T) { } } +func TestPackagesTestPath(t *testing.T) { + p := Package{} + if p.TestPath() != "./..." { + t.Fail() + } + + p.Test = "./sub" + if p.TestPath() != "./sub" { + t.Fail() + } +} + func TestLoadPackages(t *testing.T) { r := strings.NewReader(`[{"unknown_field": "value"}]`) _, err := LoadPackages(r) diff --git a/tests/thirdparty/packages.json b/tests/thirdparty/packages.json index 3c91f2b..d819a56 100644 --- a/tests/thirdparty/packages.json +++ b/tests/thirdparty/packages.json @@ -130,5 +130,22 @@ "primitivefuncs_amd64.s" ] ] + }, + { + "import_path": "github.com/klauspost/compress", + "version": "23a5980ed240fd76b89481403c834f48943b3788", + "dir": "s2", + "generate": [ + [ + "go", + "run", + "gen.go", + "-out", + "encodeblock_amd64.s", + "-stubs", + "encodeblock_amd64.go" + ] + ], + "test": "./s2" } ] diff --git a/tests/thirdparty/packages_test.go b/tests/thirdparty/packages_test.go index 42118d6..5a1c97d 100644 --- a/tests/thirdparty/packages_test.go +++ b/tests/thirdparty/packages_test.go @@ -145,7 +145,7 @@ func (t *PackageTest) diff() { // test runs go test. func (t *PackageTest) test() { - t.gotool("test", "./...") + t.gotool("test", t.TestPath()) } // git runs a git command.