summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2014-11-03 13:41:03 -0500
committerAlan Donovan <adonovan@google.com>2014-11-03 13:41:03 -0500
commit3ad646b1c04ba64796abf1aab9f9af1bee6e6719 (patch)
treee0b438aa93bcda72036831d434af0ad0189daefb /misc
parenta431c9ab04725cdadea4f7d191983206cc01437a (diff)
downloadgo-3ad646b1c04ba64796abf1aab9f9af1bee6e6719.tar.gz
misc/cgo/test: fix freebsd test failure by moving test to its own package.
(The assertion depends on a per-package gensym counter whose value varies based on what else is in the package.) LGTM=khr R=khr, rsc CC=golang-codereviews https://codereview.appspot.com/169930043
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/test/issue9026.go30
-rw-r--r--misc/cgo/test/issue9026/issue9026.go36
2 files changed, 39 insertions, 27 deletions
diff --git a/misc/cgo/test/issue9026.go b/misc/cgo/test/issue9026.go
index b5d975f17..8848d0e81 100644
--- a/misc/cgo/test/issue9026.go
+++ b/misc/cgo/test/issue9026.go
@@ -1,33 +1,9 @@
package cgotest
-/*
-typedef struct {} git_merge_file_input;
-
-typedef struct {} git_merge_file_options;
-
-void git_merge_file(
- git_merge_file_input *in,
- git_merge_file_options *opts) {}
-*/
-import "C"
import (
- "fmt"
"testing"
-)
-func test9026(t *testing.T) {
- var in C.git_merge_file_input
- var opts *C.git_merge_file_options
- C.git_merge_file(&in, opts)
+ "./issue9026"
+)
- // Test that the generated type names are deterministic.
- // (Previously this would fail about 10% of the time.)
- //
- // Brittle: the assertion may fail spuriously when the algorithm
- // changes, but should remain stable otherwise.
- got := fmt.Sprintf("%T %T", in, opts)
- want := "cgotest._Ctype_struct___12 *cgotest._Ctype_struct___13"
- if got != want {
- t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
- }
-}
+func test9026(t *testing.T) { issue9026.Test(t) }
diff --git a/misc/cgo/test/issue9026/issue9026.go b/misc/cgo/test/issue9026/issue9026.go
new file mode 100644
index 000000000..0af86e64d
--- /dev/null
+++ b/misc/cgo/test/issue9026/issue9026.go
@@ -0,0 +1,36 @@
+package issue9026
+
+// This file appears in its own package since the assertion tests the
+// per-package counter used to create fresh identifiers.
+
+/*
+typedef struct {} git_merge_file_input;
+
+typedef struct {} git_merge_file_options;
+
+void git_merge_file(
+ git_merge_file_input *in,
+ git_merge_file_options *opts) {}
+*/
+import "C"
+import (
+ "fmt"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ var in C.git_merge_file_input
+ var opts *C.git_merge_file_options
+ C.git_merge_file(&in, opts)
+
+ // Test that the generated type names are deterministic.
+ // (Previously this would fail about 10% of the time.)
+ //
+ // Brittle: the assertion may fail spuriously when the algorithm
+ // changes, but should remain stable otherwise.
+ got := fmt.Sprintf("%T %T", in, opts)
+ want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1"
+ if got != want {
+ t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
+ }
+}