aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Polański <michal@polanski.me>2020-05-24 00:30:26 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2020-05-28 15:06:54 +0000
commit1cf4652f8b8a73962c81da14e8cd115d3d7c0b3f (patch)
tree9ff8f370379c8b52c2c9870f1a2e7025c49471ac
parent11e9491c7c804e82dc45dff606db647a51cc4e0b (diff)
downloadalpine_aports-1cf4652f8b8a73962c81da14e8cd115d3d7c0b3f.tar.bz2
alpine_aports-1cf4652f8b8a73962c81da14e8cd115d3d7c0b3f.tar.xz
alpine_aports-1cf4652f8b8a73962c81da14e8cd115d3d7c0b3f.zip
testing/shfmt: fix tests on 32-bit architectures
-rw-r--r--testing/shfmt/APKBUILD6
-rw-r--r--testing/shfmt/fix-tests-32bit.patch87
2 files changed, 91 insertions, 2 deletions
diff --git a/testing/shfmt/APKBUILD b/testing/shfmt/APKBUILD
index 9da2399464..c46e0407dd 100644
--- a/testing/shfmt/APKBUILD
+++ b/testing/shfmt/APKBUILD
@@ -8,7 +8,8 @@ url="https://mvdan.cc/sh"
8arch="all" 8arch="all"
9license="BSD-3-Clause" 9license="BSD-3-Clause"
10makedepends="go" 10makedepends="go"
11source="$pkgname-$pkgver.tar.gz::https://github.com/mvdan/sh/archive/v$pkgver.tar.gz" 11source="$pkgname-$pkgver.tar.gz::https://github.com/mvdan/sh/archive/v$pkgver.tar.gz
12 fix-tests-32bit.patch"
12builddir="$srcdir/sh-$pkgver" 13builddir="$srcdir/sh-$pkgver"
13 14
14build() { 15build() {
@@ -26,4 +27,5 @@ package() {
26 install -Dm755 shfmt "$pkgdir"/usr/bin/shfmt 27 install -Dm755 shfmt "$pkgdir"/usr/bin/shfmt
27} 28}
28 29
29sha512sums="3cfca494b1c3d87b7b5cf6435909637ee6e15147fe35a1f628a1c9f127c884efa4aae9e2e1dec989ff6a32cbad08cea925c6c427f9fe7ebe41333326d1ea747c shfmt-3.1.1.tar.gz" 30sha512sums="3cfca494b1c3d87b7b5cf6435909637ee6e15147fe35a1f628a1c9f127c884efa4aae9e2e1dec989ff6a32cbad08cea925c6c427f9fe7ebe41333326d1ea747c shfmt-3.1.1.tar.gz
31dcf910ee55f41a4b14ff78554103a8913820315975246bb2ba387a3ae872cbda4ec5082741e3bde8161daa1a61ef3c419f26db35c26d8a75d69803b3ab63352b fix-tests-32bit.patch"
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