cmd/go/internal/work: add missing newline to go version note

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>
This commit is contained in:
Bryan C. Mills 2020-10-01 10:53:41 -04:00
parent c7233dd063
commit d70a33a40b
2 changed files with 40 additions and 3 deletions

View 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
}

View 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)
}
}