]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pack: don't look for " in output from go env
authorRob Pike <r@golang.org>
Wed, 19 Feb 2014 23:33:47 +0000 (15:33 -0800)
committerRob Pike <r@golang.org>
Wed, 19 Feb 2014 23:33:47 +0000 (15:33 -0800)
Windows at least doesn't emit one.
Maybe fix Windows build.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/66120046

src/cmd/pack/pack_test.go

index a073fa45210b3febb98de36ac92ccc7729e71167..cab236fa8884ed6ea3a8128919d972d7afc8c0a1 100644 (file)
@@ -12,7 +12,7 @@ import (
        "os"
        "os/exec"
        "path/filepath"
-       "strings"
+       "regexp"
        "testing"
        "time"
        "unicode/utf8"
@@ -193,11 +193,15 @@ func TestHello(t *testing.T) {
        }
 
        out := run("go", "env")
-       i := strings.Index(out, "GOCHAR=\"")
-       if i < 0 {
+       re, err := regexp.Compile(`\s*GOCHAR="?(\w)"?`)
+       if err != nil {
+               t.Fatal(err)
+       }
+       fields := re.FindStringSubmatch(out)
+       if fields == nil {
                t.Fatal("cannot find GOCHAR in 'go env' output:\n", out)
        }
-       char := out[i+8 : i+9]
+       char := fields[1]
        run("go", "build", "cmd/pack") // writes pack binary to dir
        run("go", "tool", char+"g", "hello.go")
        run("./pack", "grc", "hello.a", "hello."+char)