From 8df9913bb75718f69c738ad361c1fc45b236e567 Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Wed, 27 Oct 2021 22:59:40 +0700 Subject: [PATCH] test: approach of getting goroot --- .github/workflows/ci.yml | 17 ----------------- decrr_test.go | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 241857d..2494f87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,23 +3,6 @@ name: CI on: [push, pull_request] jobs: - build-test: - name: Build test - runs-on: ubuntu-latest - strategy: - matrix: - go-version: [1.16.x, 1.17.x] - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - name: Build - run: go build . coverage: name: Coverage runs-on: ubuntu-latest diff --git a/decrr_test.go b/decrr_test.go index a837fb0..e3e3b75 100644 --- a/decrr_test.go +++ b/decrr_test.go @@ -3,6 +3,8 @@ package decrr_test import ( "errors" "os" + "os/exec" + "strings" "testing" "github.com/aldy505/decrr" @@ -13,11 +15,18 @@ func TestWrap(t *testing.T) { w := decrr.Wrap(x) wd, _ := os.Getwd() + cmd, err := exec.Command("bash", "-c", "go env | grep GOROOT").CombinedOutput() + if err != nil { + t.Error(err) + } + + gt := strings.Replace(strings.Replace(strings.Replace(string(cmd), "GOROOT=", "", 1), "\"", "", 2), "\n", "", -1) + var expected string expected += "why does a chicken cross the road?\n\n" - expected += "github.com/aldy505/decrr_test.TestWrap " + wd + "/decrr_test.go:13\n" - expected += "testing.tRunner /usr/local/go/src/testing/testing.go:1259\n" - expected += "runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:1581" + expected += "github.com/aldy505/decrr_test.TestWrap " + wd + "/decrr_test.go:15\n" + expected += "testing.tRunner " + gt + "/src/testing/testing.go:1259\n" + expected += "runtime.goexit " + gt + "/src/runtime/asm_amd64.s:1581" if w.Error() != expected { t.Error("different than expected:", w.Error(), "\nexpected:", expected)