diff options
Diffstat (limited to 'community/shfmt/fix-tests-32bit.patch')
-rw-r--r-- | community/shfmt/fix-tests-32bit.patch | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/community/shfmt/fix-tests-32bit.patch b/community/shfmt/fix-tests-32bit.patch new file mode 100644 index 00000000000..b2e143a535d --- /dev/null +++ b/community/shfmt/fix-tests-32bit.patch @@ -0,0 +1,87 @@ +From 1fc115c28c80db7d0af25b87bdb35811ef7e10a3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20Mart=C3=AD?= <mvdan@mvdan.cc> +Date: Sat, 23 May 2020 21:35:38 +0100 +Subject: [PATCH] interp: fix tests on 32-bit architectures + +Three test cases assumed 64-bit integer sizes. Fix that, and make sure +that our amd64 CI runners also test with GOARCH=386, to catch such +future mistakes. + +While at it, update the alpine image version for CI. + +Fixes #571. +--- + .github/workflows/test.yml | 5 ++++- + interp/interp_test.go | 17 +++++++++++++---- + 2 files changed, 17 insertions(+), 5 deletions(-) + +diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml +index 166d9018..1d1375ea 100644 +--- a/.github/workflows/test.yml ++++ b/.github/workflows/test.yml +@@ -21,6 +21,9 @@ jobs: + - name: Test with -short -race + run: go test -short -race -count=1 ./... + ++ - name: Test with GOARCH=386 ++ run: GOARCH=386 go test -count=1 ./... ++ if: matrix.platform == 'ubuntu-latest' + - name: gofmt check + run: diff <(echo -n) <(gofmt -d .) + if: matrix.platform == 'ubuntu-latest' +@@ -31,7 +34,7 @@ jobs: + - name: Checkout code + uses: actions/checkout@v2 + - name: Test as root, without cgo, and with busybox +- run: docker run -v="$PWD:/pwd" -w=/pwd -e=CGO_ENABLED=0 golang:1.14.1-alpine go test ./... ++ run: docker run -v="$PWD:/pwd" -w=/pwd -e=CGO_ENABLED=0 golang:1.14.3-alpine go test ./... + + fuzz: + runs-on: ubuntu-latest +diff --git a/interp/interp_test.go b/interp/interp_test.go +index 9b4d43e2..52589281 100644 +--- a/interp/interp_test.go ++++ b/interp/interp_test.go +@@ -9,6 +9,7 @@ import ( + "fmt" + "io" + "io/ioutil" ++ "math/bits" + "os" + "os/exec" + "path/filepath" +@@ -269,9 +270,6 @@ var runTests = []runTest{ + {"printf %d,%i 3 4", "3,4"}, + {"printf %d", "0"}, + {"printf %d,%d 010 0x10", "8,16"}, +- {"printf %i,%u -3 -3", "-3,18446744073709551613"}, +- {"printf %o -3", "1777777777777777777775"}, +- {"printf %x -3", "fffffffffffffffd"}, + {"printf %c,%c,%c foo àa", "f,\xc3,\x00"}, // TODO: use a rune? + {"printf %3s a", " a"}, + {"printf %3i 1", " 1"}, +@@ -2624,12 +2622,23 @@ var runTestsWindows = []runTest{ + {"cmd() { :; }; command cmd /c 'echo foo'", "foo\r\n"}, + } + ++// These tests are specific to 64-bit architectures, and that's fine. We don't ++// need to add explicit versions for 32-bit. ++var runTests64bit = []runTest{ ++ {"printf %i,%u -3 -3", "-3,18446744073709551613"}, ++ {"printf %o -3", "1777777777777777777775"}, ++ {"printf %x -3", "fffffffffffffffd"}, ++} ++ + func init() { + if runtime.GOOS == "windows" { + runTests = append(runTests, runTestsWindows...) +- } else { ++ } else { // Unix-y + runTests = append(runTests, runTestsUnix...) + } ++ if bits.UintSize == 64 { ++ runTests = append(runTests, runTests64bit...) ++ } + } + + // ln -s: wine doesn't implement symlinks; see https://bugs.winehq.org/show_bug.cgi?id=44948 |