]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/work: add missing newline to go version note
authorBryan C. Mills <bcmills@google.com>
Thu, 1 Oct 2020 14:53:41 +0000 (10:53 -0400)
committerBryan C. Mills <bcmills@google.com>
Mon, 16 Nov 2020 15:39:19 +0000 (15:39 +0000)
A missed newline was added for one case in CL 162957, but
the parallel no-output case was missed.

Add the missed newline for the second case and update the test to
cover the full line for both cases.

Updates #30263

Change-Id: I02aa523290295a6d409cd68066b45c6990e6fb6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/258758
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>

src/cmd/go/internal/work/exec.go
src/cmd/go/testdata/script/mod_go_version.txt

index 157ac4cafc7060a41b6f2583dff5f7c34c9ff433..6ce56dd6f497e0444c24cb6455b6350b42dbd777 100644 (file)
@@ -766,7 +766,7 @@ OverlayLoop:
        }
        if err != nil {
                if p.Module != nil && !allowedVersion(p.Module.GoVersion) {
-                       b.showOutput(a, a.Package.Dir, a.Package.Desc(), "note: module requires Go "+p.Module.GoVersion)
+                       b.showOutput(a, a.Package.Dir, a.Package.Desc(), "note: module requires Go "+p.Module.GoVersion+"\n")
                }
                return err
        }
index 37f173531b699b83800216196d29418f7a178bfe..97d9975e6806060fa1f1a4d3f94454b37c06bedc 100644 (file)
@@ -8,12 +8,19 @@ go build sub.1
 go build subver.1
 ! stderr 'module requires'
 ! go build badsub.1
-stderr 'module requires Go 1.11111'
+stderr '^note: module requires Go 1.11111$'
 
 go build versioned.1
 go mod edit -require versioned.1@v1.1.0
 ! go build versioned.1
-stderr 'module requires Go 1.99999'
+stderr '^note: module requires Go 1.99999$'
+
+[short] stop
+
+# The message should be printed even if the compiler emits no output.
+go build -o $WORK/nooutput.exe nooutput.go
+! go build -toolexec=$WORK/nooutput.exe versioned.1
+stderr '^# versioned.1\nnote: module requires Go 1.99999$'
 
 -- go.mod --
 module m
@@ -71,3 +78,33 @@ go 1.99999
 -- versioned2/x.go --
 package x
 invalid syntax
+
+-- nooutput.go --
+// +build ignore
+
+package main
+
+import (
+       "bytes"
+       "os"
+       "os/exec"
+       "strings"
+)
+
+func main() {
+       stderr := new(bytes.Buffer)
+       stdout := new(bytes.Buffer)
+
+       cmd := exec.Command(os.Args[1], os.Args[2:]...)
+       cmd.Stderr = stderr
+       cmd.Stdout = stdout
+
+       err := cmd.Run()
+       if strings.HasPrefix(os.Args[2], "-V") {
+               os.Stderr.Write(stderr.Bytes())
+               os.Stdout.Write(stdout.Bytes())
+       }
+       if err != nil {
+               os.Exit(1)
+       }
+}