]> Cypherpunks repositories - gostls13.git/commitdiff
test: move linkx and sinit to run.go
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 6 Nov 2014 20:14:08 +0000 (15:14 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 6 Nov 2014 20:14:08 +0000 (15:14 -0500)
The remaining run-only tests will be migrated to run.go in another CL.

This CL will break the build due to issues 8746 and 8806.

Update #4139
Update #8746
Update #8806

LGTM=rsc
R=rsc, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/144630044

test/linkx.go
test/linkx_run.go [new file with mode: 0644]
test/run.go
test/sinit.go
test/sinit_run.go [new file with mode: 0644]

index 06888a229ae4d1c55a1a57966ea3f90d6d4f0cab..151b6db1eca8aaa793258d1aa6eeb89ece04f64d 100644 (file)
@@ -1,13 +1,11 @@
-// $G $D/$F.go && $L -X main.tbd hello -X main.overwrite trumped -X main.nosuchsymbol neverseen $F.$A && ./$A.out
-
-// NOTE: This test is not run by 'run.go' and so not run by all.bash.
-// To run this test you must use the ./run shell script.
+// skip
 
 // Copyright 2012 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.
 
 // Test the -X facility of the gc linker (6l etc.).
+// This test is run by linkx_run.go.
 
 package main
 
@@ -15,10 +13,6 @@ var tbd string
 var overwrite string = "dibs"
 
 func main() {
-       if tbd != "hello" {
-               println("BUG: test/linkx tbd", len(tbd), tbd)
-       }
-       if overwrite != "trumped" {
-               println("BUG: test/linkx overwrite", len(overwrite), overwrite)
-       }
+       println(tbd)
+       println(overwrite)
 }
diff --git a/test/linkx_run.go b/test/linkx_run.go
new file mode 100644 (file)
index 0000000..abfc342
--- /dev/null
@@ -0,0 +1,32 @@
+// run
+
+// Copyright 2014 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.
+
+// Run the linkx test.
+
+package main
+
+import (
+       "fmt"
+       "os"
+       "os/exec"
+)
+
+func main() {
+       cmd := exec.Command("go", "run", "-ldflags=-X main.tbd hello -X main.overwrite trumped", "linkx.go")
+       out, err := cmd.CombinedOutput()
+       if err != nil {
+               fmt.Println(string(out))
+               fmt.Println(err)
+               os.Exit(1)
+       }
+
+       want := "hello\ntrumped\n"
+       got := string(out)
+       if got != want {
+               fmt.Printf("got %q want %q\n", got, want)
+               os.Exit(1)
+       }
+}
index 28882cf54c2d700d73ff025a6cb327268b34fc63..e8ec2df9c4ee22cff9c47bbf9657ac5237e0d9d0 100644 (file)
@@ -907,8 +907,6 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) {
 }
 
 var skipOkay = map[string]bool{
-       "linkx.go":            true, // like "run" but wants linker flags
-       "sinit.go":            true,
        "fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir.
        "fixedbugs/bug302.go": true, // tests both .$O and .a imports.
        "fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation.
index 52dfd6fe44654362bef3eab99a6f5b8cbc4a2c8b..df1a4cc930ca784b3ae166f71db16f9f03ab54a5 100644 (file)
@@ -1,7 +1,4 @@
-// $G -S $D/$F.go | egrep initdone >/dev/null && echo BUG sinit || true
-
-// NOTE: This test is not run by 'run.go' and so not run by all.bash.
-// To run this test you must use the ./run shell script.
+// skip
 
 // Copyright 2010 The Go Authors.  All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -9,6 +6,7 @@
 
 // Test that many initializations can be done at link time and
 // generate no executable init functions.
+// This test is run by sinit_run.go.
 
 package p
 
@@ -106,12 +104,12 @@ var answers = [...]int{
 }
 
 var (
-       copy_zero = zero
-       copy_one = one
-       copy_pi = pi
-       copy_slice = slice
+       copy_zero     = zero
+       copy_one      = one
+       copy_pi       = pi
+       copy_slice    = slice
        copy_sliceInt = sliceInt
-       copy_hello = hello
+       copy_hello    = hello
 
        // Could be handled without an initialization function, but
        // requires special handling for "a = []byte("..."); b = a"
@@ -121,12 +119,12 @@ var (
        // make this special case work.
 
        copy_four, copy_five = four, five
-       copy_x, copy_y = x, y
-       copy_nilslice = nilslice
-       copy_nilmap = nilmap
-       copy_nilfunc = nilfunc
-       copy_nilchan = nilchan
-       copy_nilptr = nilptr
+       copy_x, copy_y       = x, y
+       copy_nilslice        = nilslice
+       copy_nilmap          = nilmap
+       copy_nilfunc         = nilfunc
+       copy_nilchan         = nilchan
+       copy_nilptr          = nilptr
 )
 
 var copy_a = a
@@ -179,7 +177,7 @@ var sx []int
 var s0 = []int{0, 0, 0}
 var s1 = []int{1, 2, 3}
 
-func fi() int
+func fi() int { return 1 }
 
 var ax [10]int
 var a0 = [10]int{0, 0, 0}
@@ -281,6 +279,8 @@ type T1 int
 
 func (t *T1) M() {}
 
-type Mer interface { M() }
+type Mer interface {
+       M()
+}
 
 var _ Mer = (*T1)(nil)
diff --git a/test/sinit_run.go b/test/sinit_run.go
new file mode 100644 (file)
index 0000000..a21bd10
--- /dev/null
@@ -0,0 +1,39 @@
+// run
+
+// Copyright 2014 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.
+
+// Run the sinit test.
+
+package main
+
+import (
+       "bytes"
+       "fmt"
+       "go/build"
+       "os"
+       "os/exec"
+)
+
+func main() {
+       letter, err := build.ArchChar(build.Default.GOARCH)
+       if err != nil {
+               fmt.Println(err)
+               os.Exit(1)
+       }
+
+       cmd := exec.Command("go", "tool", letter+"g", "-S", "sinit.go")
+       out, err := cmd.CombinedOutput()
+       if err != nil {
+               fmt.Println(string(out))
+               fmt.Println(err)
+               os.Exit(1)
+       }
+       os.Remove("sinit." + letter)
+
+       if bytes.Contains(out, []byte("initdone")) {
+               fmt.Println("sinit generated an init function")
+               os.Exit(1)
+       }
+}