mirror of
https://github.com/golang/go
synced 2024-09-30 11:28:36 -06:00
cmd/go: bypass install to os.DevNull entirely, test mayberemovefile(os.DevNull)
Fixes #16811. Change-Id: I7d018015f691838482ccf845d621209b96935ba4 Reviewed-on: https://go-review.googlesource.com/31657 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Quentin Smith <quentin@golang.org>
This commit is contained in:
parent
3ef07c412f
commit
a3faa80033
@ -470,6 +470,11 @@ func runBuild(cmd *Command, args []string) {
|
||||
*buildO += exeSuffix
|
||||
}
|
||||
|
||||
// Special case -o /dev/null by not writing at all.
|
||||
if *buildO == os.DevNull {
|
||||
*buildO = ""
|
||||
}
|
||||
|
||||
// sanity check some often mis-used options
|
||||
switch buildContext.Compiler {
|
||||
case "gccgo":
|
||||
|
25
src/cmd/go/build_test.go
Normal file
25
src/cmd/go/build_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRemoveDevNull(t *testing.T) {
|
||||
fi, err := os.Lstat(os.DevNull)
|
||||
if err != nil {
|
||||
t.Skip(err)
|
||||
}
|
||||
if fi.Mode().IsRegular() {
|
||||
t.Errorf("Lstat(%s).Mode().IsRegular() = true; expected false", os.DevNull)
|
||||
}
|
||||
mayberemovefile(os.DevNull)
|
||||
_, err = os.Lstat(os.DevNull)
|
||||
if err != nil {
|
||||
t.Errorf("mayberemovefile(%s) did remove it; oops", os.DevNull)
|
||||
}
|
||||
}
|
@ -1334,9 +1334,6 @@ func TestInstallIntoGOPATH(t *testing.T) {
|
||||
|
||||
// Issue 12407
|
||||
func TestBuildOutputToDevNull(t *testing.T) {
|
||||
if runtime.GOOS == "plan9" {
|
||||
t.Skip("skipping because /dev/null is a regular file on plan9")
|
||||
}
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
|
||||
|
Loading…
Reference in New Issue
Block a user