-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: integration tests for third-party packages (#112)
Closes #103
- Loading branch information
1 parent
49adad9
commit 205fc6a
Showing
6 changed files
with
437 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Package thirdparty executes integration tests based on third-party packages that use avo. | ||
package thirdparty | ||
|
||
import ( | ||
"encoding/json" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// Package defines an integration test based on a third-party package using avo. | ||
type Package struct { | ||
ImportPath string `json:"import_path"` // package import path | ||
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 | ||
} | ||
|
||
// Name returns the package name. | ||
func (p Package) Name() string { | ||
return filepath.Base(p.ImportPath) | ||
} | ||
|
||
// CloneURL returns the git clone URL. | ||
func (p Package) CloneURL() string { | ||
return "https://" + p.ImportPath + ".git" | ||
} | ||
|
||
// LoadPackages loads a list of package configurations from JSON format. | ||
func LoadPackages(r io.Reader) ([]Package, error) { | ||
var pkgs []Package | ||
d := json.NewDecoder(r) | ||
d.DisallowUnknownFields() | ||
if err := d.Decode(&pkgs); err != nil { | ||
return nil, err | ||
} | ||
return pkgs, nil | ||
} | ||
|
||
// LoadPackagesFile loads a list of package configurations from a JSON file. | ||
func LoadPackagesFile(filename string) ([]Package, error) { | ||
f, err := os.Open(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer f.Close() | ||
return LoadPackages(f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package thirdparty | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestPackageName(t *testing.T) { | ||
p := Package{ImportPath: "github.com/username/repo"} | ||
if p.Name() != "repo" { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestPackageCloneURL(t *testing.T) { | ||
p := Package{ImportPath: "github.com/username/repo"} | ||
if p.CloneURL() != "https://github.com/username/repo.git" { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestLoadPackages(t *testing.T) { | ||
r := strings.NewReader(`[{"unknown_field": "value"}]`) | ||
_, err := LoadPackages(r) | ||
if err == nil { | ||
t.Fatal("expected non-nil error") | ||
} | ||
} | ||
|
||
func TestLoadPackagesFile(t *testing.T) { | ||
pkgs, err := LoadPackagesFile("packages.json") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, pkg := range pkgs { | ||
t.Log(pkg.ImportPath) | ||
} | ||
if len(pkgs) == 0 { | ||
t.Fatal("no packages loaded") | ||
} | ||
} | ||
|
||
func TestLoadPackagesFileNotExist(t *testing.T) { | ||
pkgs, err := LoadPackagesFile("does_not_exist") | ||
if pkgs != nil { | ||
t.Fatal("expected nil return") | ||
} | ||
if err == nil { | ||
t.Fatal("expected non-nil error") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
[ | ||
{ | ||
"import_path": "github.com/zeebo/xxh3", | ||
"version": "65f423c10688c362d2a2ce6987b665c72ee7bddd", | ||
"dir": "avo", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
".", | ||
"-avx", | ||
"-out", | ||
"../vector_avx_amd64.s" | ||
], | ||
[ | ||
"go", | ||
"run", | ||
".", | ||
"-sse", | ||
"-out", | ||
"../vector_sse_amd64.s" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/dgryski/go-sip13", | ||
"version": "25c5027a8c7bfa6dab4b577e53e5c9068f6e2152", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"_avo/asm.go", | ||
"-out", | ||
"sip13_amd64.s" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/orisano/wyhash", | ||
"version": "32a3f7f6ba4797e2d87dab2969cc9dd63d39cce9", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"avo/gen.go", | ||
"-out", | ||
"blocks_amd64.s", | ||
"-stubs", | ||
"blocks_amd64.go" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/dgryski/go-bloomindex", | ||
"version": "0902316dce158c154b958ee5cfc706c62af29a42", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"asm.go", | ||
"-out", | ||
"query_amd64.s" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/dgryski/go-marvin32", | ||
"version": "7d18f4c6ea7c24b29d1c7a670f8ae40b0812f2e3", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"asm.go", | ||
"-out", | ||
"marvin_amd64.s" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/dgryski/go-speck", | ||
"version": "5b36d4c08d8840c352a153bf37281434ad550ec0", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"asm.go", | ||
"-out", | ||
"speck_amd64.s" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/dgryski/go-chaskey", | ||
"version": "ba454392bc5ab6daae103e15147185f8f4a27dcc", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"asm.go", | ||
"-out", | ||
"core_amd64.s" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/mkevac/gopherconrussia2019", | ||
"version": "235b8b0156a20b4e078b88462e669730f99caeb1", | ||
"dir": "simplesimd", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"asm.go", | ||
"-out", | ||
"simd.s", | ||
"-stubs", | ||
"stub.go" | ||
] | ||
] | ||
}, | ||
{ | ||
"import_path": "github.com/phoreproject/bls", | ||
"version": "9d5f85bf4a9badf491a1b9b27fb3344b489bd2c4", | ||
"generate": [ | ||
[ | ||
"go", | ||
"run", | ||
"asm/asm.go", | ||
"-out", | ||
"primitivefuncs_amd64.s" | ||
] | ||
] | ||
} | ||
] |
Oops, something went wrong.