tests/thirdparty: add crypto/internal/bigmod (#355)
Add test case for avo generator in standard library crypto/internal/bigmod. https://github.com/golang/go/tree/go1.20rc2/src/crypto/internal/bigmod https://golang.org/cl/452095 https://words.filippo.io/dispatches/go-1-20-cryptography/ Closes #354
This commit is contained in:
committed by
GitHub
parent
67039b7ed9
commit
12b5abca55
48
tests/thirdparty/config.go
vendored
48
tests/thirdparty/config.go
vendored
@@ -132,9 +132,8 @@ func (s *Step) Validate() error {
|
||||
|
||||
// Package defines an integration test for a package within a project.
|
||||
type Package struct {
|
||||
// Sub-package within the project under test. All file path references will
|
||||
// be relative to this directory. If empty the root of the repository is
|
||||
// used.
|
||||
// Sub-package within the project under test. Used as the root directory for
|
||||
// the test unless explicitly overridden.
|
||||
SubPackage string `json:"pkg,omitempty"`
|
||||
|
||||
// Path to the module file for the avo generator package. This is necessary
|
||||
@@ -142,6 +141,11 @@ type Package struct {
|
||||
// version under test.
|
||||
Module string `json:"module"`
|
||||
|
||||
// Root directory for all steps in the test. All file path references will
|
||||
// be relative to this directory. If empty, the sub-package directory is
|
||||
// used, or otherwise the root of the repository.
|
||||
Root string `json:"root,omitempty"`
|
||||
|
||||
// Setup steps. These run prior to the insertion of avo replace directives,
|
||||
// therefore should be used if it's necessary to initialize new go modules
|
||||
// within the repository.
|
||||
@@ -219,6 +223,17 @@ func (p *Package) IsRoot() bool {
|
||||
return p.SubPackage == ""
|
||||
}
|
||||
|
||||
// WorkingDirectory returns the base directory for all steps in the test.
|
||||
func (p *Package) WorkingDirectory() string {
|
||||
if p.Root != "" {
|
||||
return p.Root
|
||||
}
|
||||
if p.SubPackage != "" {
|
||||
return p.SubPackage
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Context specifies execution environment parameters for a third-party test.
|
||||
type Context struct {
|
||||
// Path to the avo version under test.
|
||||
@@ -272,9 +287,9 @@ func (p *Package) Steps(c *Context) []*Step {
|
||||
}
|
||||
|
||||
// Prepend sub-directory to every step.
|
||||
if p.SubPackage != "" {
|
||||
if dir := p.WorkingDirectory(); dir != "" {
|
||||
for _, s := range steps {
|
||||
s.WorkingDirectory = filepath.Join(p.SubPackage, s.WorkingDirectory)
|
||||
s.WorkingDirectory = filepath.Join(dir, s.WorkingDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,20 +319,33 @@ func (p Projects) defaults(set bool) {
|
||||
|
||||
// Validate the project collection.
|
||||
func (p Projects) Validate() error {
|
||||
seen := map[string]bool{}
|
||||
// Projects are valid.
|
||||
for _, prj := range p {
|
||||
// Project is valid.
|
||||
if err := prj.Validate(); err != nil {
|
||||
return fmt.Errorf("project %s: %w", prj.ID(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// No duplicate entries.
|
||||
// No duplicate project IDs.
|
||||
pid := map[string]bool{}
|
||||
for _, prj := range p {
|
||||
id := prj.ID()
|
||||
if seen[id] {
|
||||
if pid[id] {
|
||||
return fmt.Errorf("duplicate project %q", id)
|
||||
}
|
||||
seen[id] = true
|
||||
pid[id] = true
|
||||
}
|
||||
|
||||
// No duplicate test IDs.
|
||||
tid := map[string]bool{}
|
||||
for _, t := range p.Tests() {
|
||||
id := t.ID()
|
||||
if tid[id] {
|
||||
return fmt.Errorf("duplicate test %q", id)
|
||||
}
|
||||
tid[id] = true
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
20
tests/thirdparty/packages_test.go
vendored
20
tests/thirdparty/packages_test.go
vendored
@@ -2,6 +2,7 @@ package thirdparty
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -69,6 +70,7 @@ type PackageTest struct {
|
||||
// Run the test.
|
||||
func (t *PackageTest) Run() {
|
||||
t.checkout()
|
||||
t.validate()
|
||||
t.steps()
|
||||
}
|
||||
|
||||
@@ -88,6 +90,24 @@ func (t *PackageTest) checkout() {
|
||||
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "FETCH_HEAD")
|
||||
}
|
||||
|
||||
// validate the test configuration relative to the checked out project.
|
||||
func (t *PackageTest) validate() {
|
||||
// Confirm expected directories exist.
|
||||
expect := map[string]string{
|
||||
"package": t.Package.SubPackage,
|
||||
"root": t.Package.WorkingDirectory(),
|
||||
}
|
||||
for name, subdir := range expect {
|
||||
if subdir == "" {
|
||||
continue
|
||||
}
|
||||
path := filepath.Join(t.repopath, subdir)
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
t.Fatalf("expected %s directory: %s", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *PackageTest) steps() {
|
||||
// Determine the path to avo.
|
||||
_, self, _, ok := runtime.Caller(1)
|
||||
|
||||
35
tests/thirdparty/suite.json
vendored
35
tests/thirdparty/suite.json
vendored
@@ -749,9 +749,39 @@
|
||||
"stars": 107376
|
||||
},
|
||||
"default_branch": "master",
|
||||
"version": "go1.19",
|
||||
"version": "go1.20rc2",
|
||||
"packages": [
|
||||
{
|
||||
"pkg": "src/crypto/internal/bigmod",
|
||||
"root": ".",
|
||||
"module": "src/crypto/internal/bigmod/_asm/go.mod",
|
||||
"setup": [
|
||||
{
|
||||
"name": "Compile Go Toolchain",
|
||||
"dir": "src",
|
||||
"commands": [
|
||||
"./make.bash"
|
||||
]
|
||||
}
|
||||
],
|
||||
"generate": [
|
||||
{
|
||||
"commands": [
|
||||
"env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/bigmod/_asm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
{
|
||||
"commands": [
|
||||
"env --unset=GOROOT ./bin/go test crypto/..."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pkg": "src/crypto/internal/edwards25519",
|
||||
"root": ".",
|
||||
"module": "src/crypto/internal/edwards25519/field/_asm/go.mod",
|
||||
"setup": [
|
||||
{
|
||||
@@ -764,9 +794,8 @@
|
||||
],
|
||||
"generate": [
|
||||
{
|
||||
"dir": "src/crypto/internal/edwards25519/field/_asm",
|
||||
"commands": [
|
||||
"go generate -v -x"
|
||||
"env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/edwards25519/field/_asm"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user