Skip to content

Commit 48989d5

Browse files
author
Bryan C. Mills
committed
cmd/go: convert DevNull tests to script tests
I'm hoping to eliminate testdata/src/go-cmd-test, so porting over tests that assume its existence. Updates #28387 Updates #30316 Change-Id: I20bae780a4eb87cc19cc1e8531b84ab4a8a3c255 Reviewed-on: https://go-review.googlesource.com/c/go/+/207608 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 9665be3 commit 48989d5

File tree

3 files changed

+26
-53
lines changed

3 files changed

+26
-53
lines changed

src/cmd/go/go_test.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,44 +1380,6 @@ func TestInstallIntoGOPATH(t *testing.T) {
13801380
tg.wantExecutable("testdata/bin/go-cmd-test"+exeSuffix, "go install go-cmd-test did not write to testdata/bin/go-cmd-test")
13811381
}
13821382

1383-
// Issue 12407
1384-
func TestBuildOutputToDevNull(t *testing.T) {
1385-
tg := testgo(t)
1386-
defer tg.cleanup()
1387-
fi1, err1 := os.Lstat(os.DevNull)
1388-
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
1389-
tg.run("build", "-o", os.DevNull, "go-cmd-test")
1390-
fi2, err2 := os.Lstat(os.DevNull)
1391-
if err1 == nil {
1392-
if err2 != nil {
1393-
t.Errorf("second stat of /dev/null failed: %v", err2)
1394-
} else if !os.SameFile(fi1, fi2) {
1395-
t.Errorf("/dev/null changed: now %v was %v", fi1, fi2)
1396-
}
1397-
}
1398-
}
1399-
1400-
// Issue 28549.
1401-
func TestTestOutputToDevNull(t *testing.T) {
1402-
tg := testgo(t)
1403-
defer tg.cleanup()
1404-
fi1, err1 := os.Lstat(os.DevNull)
1405-
tg.makeTempdir()
1406-
tg.setenv("GOPATH", tg.path("."))
1407-
tg.tempFile("src/p/p.go", "package p\n")
1408-
tg.tempFile("src/p/p_test.go", "package p\nimport \"testing\"\nfunc TestX(t *testing.T) {}\n")
1409-
tg.run("test", "-o", os.DevNull, "-c", "p")
1410-
tg.mustNotExist("p.test")
1411-
fi2, err2 := os.Lstat(os.DevNull)
1412-
if err1 == nil {
1413-
if err2 != nil {
1414-
t.Errorf("second stat of /dev/null failed: %v", err2)
1415-
} else if !os.SameFile(fi1, fi2) {
1416-
t.Errorf("/dev/null changed: now %v was %v", fi1, fi2)
1417-
}
1418-
}
1419-
}
1420-
14211383
func TestPackageMainTestImportsArchiveNotBinary(t *testing.T) {
14221384
tooSlow(t)
14231385
tg := testgo(t)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
env GO111MODULE=off
2+
3+
# Issue 28035: go test -c -o NUL should work.
4+
# Issue 28549: go test -c -o /dev/null should not overwrite /dev/null when run as root.
5+
cd x
6+
cmp $devnull $WORK/empty.txt
7+
go test -o=$devnull -c
8+
! exists x.test$GOEXE
9+
cmp $devnull $WORK/empty.txt
10+
11+
# Issue 12407: go build -o /dev/null should succeed.
12+
cd ..
13+
go build -o $devnull y
14+
cmp $devnull $WORK/empty.txt
15+
16+
-- x/x_test.go --
17+
package x_test
18+
import (
19+
"testing"
20+
)
21+
func TestNUL(t *testing.T) {
22+
}
23+
-- y/y.go --
24+
package y
25+
func main() {}
26+
-- $WORK/empty.txt --

src/cmd/go/testdata/script/test_devnull.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)