tests/thirdparty: add klauspost/compress/s2 (#131)
Adds @klauspost's S2 implementation to the third party test suite. The full klauspost/compress tests are slow but we only care about the S2 sub-package. Therefore this PR also adds the option to only run a subset of the package tests, controlled by a "test" parameter in the JSON configuration. Closes #130
This commit is contained in:
committed by
GitHub
parent
e089a6c93c
commit
d51141dc8f
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -89,4 +89,4 @@ jobs:
|
|||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Run Third-Party Tests
|
- name: Run Third-Party Tests
|
||||||
working-directory: ./tests/thirdparty
|
working-directory: ./tests/thirdparty
|
||||||
run: go test -v -pkgs packages.json
|
run: go test -pkgs packages.json
|
||||||
|
|||||||
9
tests/thirdparty/config.go
vendored
9
tests/thirdparty/config.go
vendored
@@ -14,6 +14,7 @@ type Package struct {
|
|||||||
Version string `json:"version"` // git sha, tag or branch
|
Version string `json:"version"` // git sha, tag or branch
|
||||||
Generate [][]string `json:"generate"` // generate commands to run
|
Generate [][]string `json:"generate"` // generate commands to run
|
||||||
Dir string `json:"dir"` // working directory for generate commands
|
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.
|
// Name returns the package name.
|
||||||
@@ -26,6 +27,14 @@ func (p Package) CloneURL() string {
|
|||||||
return "https://" + p.ImportPath + ".git"
|
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.
|
// LoadPackages loads a list of package configurations from JSON format.
|
||||||
func LoadPackages(r io.Reader) ([]Package, error) {
|
func LoadPackages(r io.Reader) ([]Package, error) {
|
||||||
var pkgs []Package
|
var pkgs []Package
|
||||||
|
|||||||
12
tests/thirdparty/config_test.go
vendored
12
tests/thirdparty/config_test.go
vendored
@@ -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) {
|
func TestLoadPackages(t *testing.T) {
|
||||||
r := strings.NewReader(`[{"unknown_field": "value"}]`)
|
r := strings.NewReader(`[{"unknown_field": "value"}]`)
|
||||||
_, err := LoadPackages(r)
|
_, err := LoadPackages(r)
|
||||||
|
|||||||
17
tests/thirdparty/packages.json
vendored
17
tests/thirdparty/packages.json
vendored
@@ -130,5 +130,22 @@
|
|||||||
"primitivefuncs_amd64.s"
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
2
tests/thirdparty/packages_test.go
vendored
2
tests/thirdparty/packages_test.go
vendored
@@ -145,7 +145,7 @@ func (t *PackageTest) diff() {
|
|||||||
|
|
||||||
// test runs go test.
|
// test runs go test.
|
||||||
func (t *PackageTest) test() {
|
func (t *PackageTest) test() {
|
||||||
t.gotool("test", "./...")
|
t.gotool("test", t.TestPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
// git runs a git command.
|
// git runs a git command.
|
||||||
|
|||||||
Reference in New Issue
Block a user