Commit a3faa800 authored by Russ Cox's avatar Russ Cox

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: default avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: default avatarQuentin Smith <quentin@golang.org>
parent 3ef07c41
...@@ -470,6 +470,11 @@ func runBuild(cmd *Command, args []string) { ...@@ -470,6 +470,11 @@ func runBuild(cmd *Command, args []string) {
*buildO += exeSuffix *buildO += exeSuffix
} }
// Special case -o /dev/null by not writing at all.
if *buildO == os.DevNull {
*buildO = ""
}
// sanity check some often mis-used options // sanity check some often mis-used options
switch buildContext.Compiler { switch buildContext.Compiler {
case "gccgo": case "gccgo":
......
// 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) { ...@@ -1334,9 +1334,6 @@ func TestInstallIntoGOPATH(t *testing.T) {
// Issue 12407 // Issue 12407
func TestBuildOutputToDevNull(t *testing.T) { func TestBuildOutputToDevNull(t *testing.T) {
if runtime.GOOS == "plan9" {
t.Skip("skipping because /dev/null is a regular file on plan9")
}
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata")) tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment