aboutsummaryrefslogtreecommitdiff
path: root/testing/shfmt/fix-tests-32bit.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/shfmt/fix-tests-32bit.patch')
-rw-r--r--testing/shfmt/fix-tests-32bit.patch87
1 files changed, 87 insertions, 0 deletions
diff --git a/testing/shfmt/fix-tests-32bit.patch b/testing/shfmt/fix-tests-32bit.patch
new file mode 100644
index 0000000000..b2e143a535
--- /dev/null
+++ b/testing/shfmt/fix-tests-32bit.patch
@@ -0,0 +1,87 @@
1From 1fc115c28c80db7d0af25b87bdb35811ef7e10a3 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Daniel=20Mart=C3=AD?= <mvdan@mvdan.cc>
3Date: Sat, 23 May 2020 21:35:38 +0100
4Subject: [PATCH] interp: fix tests on 32-bit architectures
5
6Three test cases assumed 64-bit integer sizes. Fix that, and make sure
7that our amd64 CI runners also test with GOARCH=386, to catch such
8future mistakes.
9
10While at it, update the alpine image version for CI.
11
12Fixes #571.
13---
14 .github/workflows/test.yml | 5 ++++-
15 interp/interp_test.go | 17 +++++++++++++----
16 2 files changed, 17 insertions(+), 5 deletions(-)
17
18diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
19index 166d9018..1d1375ea 100644
20--- a/.github/workflows/test.yml
21+++ b/.github/workflows/test.yml
22@@ -21,6 +21,9 @@ jobs:
23 - name: Test with -short -race
24 run: go test -short -race -count=1 ./...
25
26+ - name: Test with GOARCH=386
27+ run: GOARCH=386 go test -count=1 ./...
28+ if: matrix.platform == 'ubuntu-latest'
29 - name: gofmt check
30 run: diff <(echo -n) <(gofmt -d .)
31 if: matrix.platform == 'ubuntu-latest'
32@@ -31,7 +34,7 @@ jobs:
33 - name: Checkout code
34 uses: actions/checkout@v2
35 - name: Test as root, without cgo, and with busybox
36- run: docker run -v="$PWD:/pwd" -w=/pwd -e=CGO_ENABLED=0 golang:1.14.1-alpine go test ./...
37+ run: docker run -v="$PWD:/pwd" -w=/pwd -e=CGO_ENABLED=0 golang:1.14.3-alpine go test ./...
38
39 fuzz:
40 runs-on: ubuntu-latest
41diff --git a/interp/interp_test.go b/interp/interp_test.go
42index 9b4d43e2..52589281 100644
43--- a/interp/interp_test.go
44+++ b/interp/interp_test.go
45@@ -9,6 +9,7 @@ import (
46 "fmt"
47 "io"
48 "io/ioutil"
49+ "math/bits"
50 "os"
51 "os/exec"
52 "path/filepath"
53@@ -269,9 +270,6 @@ var runTests = []runTest{
54 {"printf %d,%i 3 4", "3,4"},
55 {"printf %d", "0"},
56 {"printf %d,%d 010 0x10", "8,16"},
57- {"printf %i,%u -3 -3", "-3,18446744073709551613"},
58- {"printf %o -3", "1777777777777777777775"},
59- {"printf %x -3", "fffffffffffffffd"},
60 {"printf %c,%c,%c foo àa", "f,\xc3,\x00"}, // TODO: use a rune?
61 {"printf %3s a", " a"},
62 {"printf %3i 1", " 1"},
63@@ -2624,12 +2622,23 @@ var runTestsWindows = []runTest{
64 {"cmd() { :; }; command cmd /c 'echo foo'", "foo\r\n"},
65 }
66
67+// These tests are specific to 64-bit architectures, and that's fine. We don't
68+// need to add explicit versions for 32-bit.
69+var runTests64bit = []runTest{
70+ {"printf %i,%u -3 -3", "-3,18446744073709551613"},
71+ {"printf %o -3", "1777777777777777777775"},
72+ {"printf %x -3", "fffffffffffffffd"},
73+}
74+
75 func init() {
76 if runtime.GOOS == "windows" {
77 runTests = append(runTests, runTestsWindows...)
78- } else {
79+ } else { // Unix-y
80 runTests = append(runTests, runTestsUnix...)
81 }
82+ if bits.UintSize == 64 {
83+ runTests = append(runTests, runTests64bit...)
84+ }
85 }
86
87 // ln -s: wine doesn't implement symlinks; see https://bugs.winehq.org/show_bug.cgi?id=44948