diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f497af..25a3d1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: required: needs: - test + - coverage - lint runs-on: ubuntu-latest steps: @@ -22,7 +23,7 @@ jobs: test: strategy: matrix: - go-version: [1.18.x, 1.19.x] + go-version: [1.19.x, 1.20.x] runs-on: ubuntu-latest steps: - name: Install Go @@ -40,6 +41,22 @@ jobs: run: go build ./... - name: Test run: go test -bench . ./... + coverage: + needs: + - test + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 + with: + go-version: 1.20.x + check-latest: true + - name: Checkout code + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + with: + persist-credentials: false + - name: Bootstrap + run: ./script/bootstrap - name: Coverage run: ./script/coverage - name: Upload Unit Test Coverage @@ -60,7 +77,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout code uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 diff --git a/.github/workflows/deps.yml b/.github/workflows/deps.yml index ecf119d..485246c 100644 --- a/.github/workflows/deps.yml +++ b/.github/workflows/deps.yml @@ -11,7 +11,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x - name: Checkout code uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 with: diff --git a/.github/workflows/metadata.yml b/.github/workflows/metadata.yml index 81b08fb..d1b3b92 100644 --- a/.github/workflows/metadata.yml +++ b/.github/workflows/metadata.yml @@ -12,7 +12,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x - name: Checkout code uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 with: diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 8cfbe4b..d371d3e 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -52,7 +52,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -98,7 +98,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -145,7 +145,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -180,7 +180,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -217,7 +217,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -252,7 +252,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -290,7 +290,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -325,7 +325,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -360,7 +360,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -410,7 +410,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -461,7 +461,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -514,7 +514,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -567,7 +567,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -612,7 +612,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -647,7 +647,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -684,7 +684,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -721,7 +721,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -756,7 +756,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -791,7 +791,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -826,7 +826,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -861,7 +861,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -901,7 +901,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -936,7 +936,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -974,7 +974,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -1012,7 +1012,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -1047,7 +1047,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 @@ -1082,7 +1082,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout avo uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 diff --git a/.github/workflows/stress.yml b/.github/workflows/stress.yml index c019a59..a83ef80 100644 --- a/.github/workflows/stress.yml +++ b/.github/workflows/stress.yml @@ -13,7 +13,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout code uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 diff --git a/.github/workflows/thirdparty.yml b/.github/workflows/thirdparty.yml index c765279..d7c47c0 100644 --- a/.github/workflows/thirdparty.yml +++ b/.github/workflows/thirdparty.yml @@ -18,7 +18,7 @@ jobs: - name: Install Go uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 with: - go-version: 1.19.x + go-version: 1.20.x check-latest: true - name: Checkout code uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 diff --git a/.golangci.yml b/.golangci.yml index 1e4894a..a4dcd1c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: disable: - cyclop - deadcode + - dupword - errname - exhaustruct - exhaustivestruct diff --git a/gotypes/signature_test.go b/gotypes/signature_test.go index 03f8e9b..07a95c5 100644 --- a/gotypes/signature_test.go +++ b/gotypes/signature_test.go @@ -3,7 +3,7 @@ package gotypes import ( "go/token" "go/types" - "strings" + "regexp" "testing" "golang.org/x/tools/go/packages" @@ -118,17 +118,22 @@ func TestParseSignature(t *testing.T) { func TestParseSignatureErrors(t *testing.T) { cases := []struct { - Expr string - ErrorContains string + Expr string + ErrorPattern string }{ - {"idkjklol", "undeclared name"}, - {"struct{}", "not a function signature"}, - {"uint32(0xfeedbeef)", "should have nil value"}, + {"idkjklol", `(undeclared|undefined)`}, // error message changed in go 1.20 + {"struct{}", `not a function signature`}, + {"uint32(0xfeedbeef)", `should have nil value`}, } for _, c := range cases { + errrx, err := regexp.Compile(c.ErrorPattern) + if err != nil { + t.Fatal(err) + } + s, err := ParseSignature(c.Expr) - if s != nil || err == nil || !strings.Contains(err.Error(), c.ErrorContains) { - t.Errorf("expect error from expression %s\ngot: %s\nexpect substring: %s\n", c.Expr, err, c.ErrorContains) + if s != nil || err == nil || !errrx.MatchString(err.Error()) { + t.Errorf("expect error from expression %s\ngot: %s\nexpect match: %s\n", c.Expr, err, c.ErrorPattern) } } } diff --git a/internal/gen/mov.go b/internal/gen/mov.go index c4e3cd0..0b1ec1e 100644 --- a/internal/gen/mov.go +++ b/internal/gen/mov.go @@ -17,7 +17,7 @@ type mov struct { } // NewMOV generates a function that will auto-select the correct MOV instruction -// based on operand types and and sizes. +// based on operand types and sizes. func NewMOV(cfg printer.Config) Interface { return GoFmt(&mov{cfg: cfg}) } diff --git a/script/bootstrap b/script/bootstrap index 6b6b135..64090e6 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -4,16 +4,13 @@ go install ./internal/cmd/asmvet # golangci-lint for linting -golangci_lint_version='v1.49.0' +golangci_lint_version='v1.51.2' golangci_install_script="https://raw.githubusercontent.com/golangci/golangci-lint/${golangci_lint_version}/install.sh" curl -sfL "${golangci_install_script}" | sh -s -- -b "$(go env GOPATH)/bin" "${golangci_lint_version}" # embedmd required for documentation generation go install github.com/campoy/embedmd@v1.0.0 -# covertool for merging coverage reports -go install github.com/dlespiau/covertool@v0.0.0-20180314162135-b0c4c6d0583a - # asmfmt for enforcing assembly style go install github.com/klauspost/asmfmt/cmd/asmfmt@v1.3.2 diff --git a/script/coverage b/script/coverage index 136a51f..db0d874 100755 --- a/script/coverage +++ b/script/coverage @@ -1,7 +1,17 @@ -#!/bin/bash -ex +#!/bin/bash + +set -euo pipefail ext=".coverprofile" +# Temporary working directory. +workdir=$(mktemp -d) + +function cleanup() { + rm -rf "${workdir}" +} +trap cleanup EXIT + # Clean existing coverage files. find . -name '*'${ext} | xargs rm -f @@ -9,16 +19,27 @@ find . -name '*'${ext} | xargs rm -f go test -covermode=count -coverprofile=unittests${ext} ./... # Integration test coverage. -coverprofiles=() +# +# Collect for each individual avo assembly generator. +coverbase="${workdir}/cover" +coversingle="${coverbase}/test" +mkdir -p "${coversingle}" + +coverdirs=() for main in $(find . -name 'asm.go'); do dir=$(dirname ${main}) name=$(basename ${dir}) - coverprofile="${dir}/${name}${ext}" - ./script/covermain ${main} ${coverprofile} > /dev/null - coverprofiles+=(${coverprofile}) + + coverdir="${coversingle}/${name}" + mkdir "${coverdir}" + GOCOVERDIR="${coverdir}" go run -tags=integration -cover "${main}" -out /dev/null + + coverdirs+=("${coverdir}") done -covertool merge --output integration${ext} ${coverprofiles[@]} - -# Merge. -covertool merge --output all${ext} unittests${ext} integration${ext} +# Merge integration test coverage. +covermergeinputs=$(IFS=","; echo "${coverdirs[*]}") +covermergeoutput="${coverbase}/merge" +mkdir "${covermergeoutput}" +go tool covdata merge -i="${covermergeinputs}" -o="${covermergeoutput}" +go tool covdata textfmt -i="${covermergeoutput}" -o="integration${ext}" diff --git a/script/covermain b/script/covermain deleted file mode 100755 index 5afbd1e..0000000 --- a/script/covermain +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -e - -main=$1 -coverprofile=$2 - -# Temporary working directory. -workdir=$(mktemp -d tmpXXXXXXXX) - -# Wrap the main function in a go test. -cp ${main} ${workdir} -cat > ${workdir}/main_test.go <