-
-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added generator and gomod-sync to linters and tests (#2426)
- Loading branch information
Showing
84 changed files
with
640 additions
and
438 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Stub tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Go ${{ matrix.go-version }} - ${{ matrix.os }}/${{ matrix.test-arch }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go-version: [1.18.x] | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
test-arch: [amd64] | ||
race: ["-race"] | ||
|
||
include: | ||
- go-version: 1.18.x | ||
test-arch: "386" | ||
os: ubuntu-latest | ||
race: "" | ||
- go-version: 1.18.x | ||
test-arch: "386" | ||
os: windows-latest | ||
race: "" | ||
|
||
steps: | ||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b | ||
|
||
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Run tests on stubs | ||
shell: bash | ||
env: | ||
GOARCH: ${{ matrix.test-arch }} | ||
run: | | ||
./bin/run-tests test-stubs |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
run: | ||
timeout: 5m | ||
timeout: 8m | ||
linters: | ||
disable-all: true | ||
enable: | ||
|
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 |
---|---|---|
@@ -1,76 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"text/template" | ||
|
||
"../../../../gen" | ||
) | ||
|
||
func main() { | ||
t, err := template.New("").Parse(tmpl) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
var j = map[string]interface{}{ | ||
"rebase": &[]testCase{}, | ||
} | ||
if err := gen.Gen("all-your-base", j, t); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
type testCase struct { | ||
Description string `json:"description"` | ||
Input struct { | ||
InputBase int `json:"inputBase"` | ||
Digits []int `json:"digits"` | ||
OutputBase int `json:"outputBase"` | ||
} `json:"input"` | ||
Expected interface{} `json:"expected"` | ||
} | ||
|
||
func (o testCase) Result() []int { | ||
s, ok := o.Expected.([]interface{}) | ||
if !ok { | ||
return nil | ||
} | ||
var res []int | ||
for _, v := range s { | ||
f, _ := v.(float64) | ||
res = append(res, int(f)) | ||
} | ||
return res | ||
} | ||
|
||
func (o testCase) Err() string { | ||
m, ok := o.Expected.(map[string]interface{}) | ||
if !ok { | ||
return "" | ||
} | ||
return m["error"].(string) | ||
} | ||
|
||
// Template to generate test cases. | ||
var tmpl = `package allyourbase | ||
{{.Header}} | ||
var testCases = []struct { | ||
description string | ||
inputBase int | ||
inputDigits []int | ||
outputBase int | ||
expected []int | ||
expectedError string | ||
}{ {{range .J.rebase}} | ||
{ | ||
description: {{printf "%q" .Description}}, | ||
inputBase: {{printf "%d" .Input.InputBase}}, | ||
inputDigits: {{printf "%#v" .Input.Digits}}, | ||
outputBase: {{printf "%d" .Input.OutputBase}}, | ||
expected: {{printf "%#v" .Result}}, | ||
expectedError: {{printf "%q" .Err}}, | ||
},{{end}} | ||
} | ||
` | ||
package main | ||
|
||
import ( | ||
"log" | ||
"text/template" | ||
|
||
"../../../../gen" | ||
) | ||
|
||
func main() { | ||
t, err := template.New("").Parse(tmpl) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
j := map[string]interface{}{ | ||
"rebase": &[]testCase{}, | ||
} | ||
if err := gen.Gen("all-your-base", j, t); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
type testCase struct { | ||
Description string `json:"description"` | ||
Input struct { | ||
InputBase int `json:"inputBase"` | ||
Digits []int `json:"digits"` | ||
OutputBase int `json:"outputBase"` | ||
} `json:"input"` | ||
Expected interface{} `json:"expected"` | ||
} | ||
|
||
func (o testCase) Result() []int { | ||
s, ok := o.Expected.([]interface{}) | ||
if !ok { | ||
return nil | ||
} | ||
var res []int | ||
for _, v := range s { | ||
f, _ := v.(float64) | ||
res = append(res, int(f)) | ||
} | ||
return res | ||
} | ||
|
||
func (o testCase) Err() string { | ||
m, ok := o.Expected.(map[string]interface{}) | ||
if !ok { | ||
return "" | ||
} | ||
return m["error"].(string) | ||
} | ||
|
||
// Template to generate test cases. | ||
var tmpl = `package allyourbase | ||
{{.Header}} | ||
var testCases = []struct { | ||
description string | ||
inputBase int | ||
inputDigits []int | ||
outputBase int | ||
expected []int | ||
expectedError string | ||
}{ {{range .J.rebase}} | ||
{ | ||
description: {{printf "%q" .Description}}, | ||
inputBase: {{printf "%d" .Input.InputBase}}, | ||
inputDigits: {{printf "%#v" .Input.Digits}}, | ||
outputBase: {{printf "%d" .Input.OutputBase}}, | ||
expected: {{printf "%#v" .Result}}, | ||
expectedError: {{printf "%q" .Err}}, | ||
},{{end}} | ||
} | ||
` |
Oops, something went wrong.