From e8db971dcdb6bdb266ccb4a5903f83978ce096f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pola=C5=84ski?= Date: Sun, 24 May 2020 00:33:56 +0200 Subject: community/shfmt: move from testing --- community/shfmt/APKBUILD | 31 +++++++++++++ community/shfmt/fix-tests-32bit.patch | 87 +++++++++++++++++++++++++++++++++++ testing/shfmt/APKBUILD | 31 ------------- testing/shfmt/fix-tests-32bit.patch | 87 ----------------------------------- 4 files changed, 118 insertions(+), 118 deletions(-) create mode 100644 community/shfmt/APKBUILD create mode 100644 community/shfmt/fix-tests-32bit.patch delete mode 100644 testing/shfmt/APKBUILD delete mode 100644 testing/shfmt/fix-tests-32bit.patch diff --git a/community/shfmt/APKBUILD b/community/shfmt/APKBUILD new file mode 100644 index 0000000000..c46e0407dd --- /dev/null +++ b/community/shfmt/APKBUILD @@ -0,0 +1,31 @@ +# Contributor: Olliver Schinagl +# Maintainer: Olliver Schinagl +pkgname=shfmt +pkgver=3.1.1 +pkgrel=0 +pkgdesc="A shell parser, formatter, and interpreter (sh/bash/mksh)" +url="https://mvdan.cc/sh" +arch="all" +license="BSD-3-Clause" +makedepends="go" +source="$pkgname-$pkgver.tar.gz::https://github.com/mvdan/sh/archive/v$pkgver.tar.gz + fix-tests-32bit.patch" +builddir="$srcdir/sh-$pkgver" + +build() { + go build \ + -ldflags "-w -X main.version=$pkgver-$pkgrel" \ + -v \ + ./cmd/shfmt +} + +check() { + go test ./... +} + +package() { + install -Dm755 shfmt "$pkgdir"/usr/bin/shfmt +} + +sha512sums="3cfca494b1c3d87b7b5cf6435909637ee6e15147fe35a1f628a1c9f127c884efa4aae9e2e1dec989ff6a32cbad08cea925c6c427f9fe7ebe41333326d1ea747c shfmt-3.1.1.tar.gz +dcf910ee55f41a4b14ff78554103a8913820315975246bb2ba387a3ae872cbda4ec5082741e3bde8161daa1a61ef3c419f26db35c26d8a75d69803b3ab63352b fix-tests-32bit.patch" diff --git a/community/shfmt/fix-tests-32bit.patch b/community/shfmt/fix-tests-32bit.patch new file mode 100644 index 0000000000..b2e143a535 --- /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?= +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 diff --git a/testing/shfmt/APKBUILD b/testing/shfmt/APKBUILD deleted file mode 100644 index c46e0407dd..0000000000 --- a/testing/shfmt/APKBUILD +++ /dev/null @@ -1,31 +0,0 @@ -# Contributor: Olliver Schinagl -# Maintainer: Olliver Schinagl -pkgname=shfmt -pkgver=3.1.1 -pkgrel=0 -pkgdesc="A shell parser, formatter, and interpreter (sh/bash/mksh)" -url="https://mvdan.cc/sh" -arch="all" -license="BSD-3-Clause" -makedepends="go" -source="$pkgname-$pkgver.tar.gz::https://github.com/mvdan/sh/archive/v$pkgver.tar.gz - fix-tests-32bit.patch" -builddir="$srcdir/sh-$pkgver" - -build() { - go build \ - -ldflags "-w -X main.version=$pkgver-$pkgrel" \ - -v \ - ./cmd/shfmt -} - -check() { - go test ./... -} - -package() { - install -Dm755 shfmt "$pkgdir"/usr/bin/shfmt -} - -sha512sums="3cfca494b1c3d87b7b5cf6435909637ee6e15147fe35a1f628a1c9f127c884efa4aae9e2e1dec989ff6a32cbad08cea925c6c427f9fe7ebe41333326d1ea747c shfmt-3.1.1.tar.gz -dcf910ee55f41a4b14ff78554103a8913820315975246bb2ba387a3ae872cbda4ec5082741e3bde8161daa1a61ef3c419f26db35c26d8a75d69803b3ab63352b fix-tests-32bit.patch" diff --git a/testing/shfmt/fix-tests-32bit.patch b/testing/shfmt/fix-tests-32bit.patch deleted file mode 100644 index b2e143a535..0000000000 --- a/testing/shfmt/fix-tests-32bit.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 1fc115c28c80db7d0af25b87bdb35811ef7e10a3 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Daniel=20Mart=C3=AD?= -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 -- cgit v1.2.3