From 680bfbb9edbd342c147fbbaadd095e2717488883 Mon Sep 17 00:00:00 2001 From: emmaxy Date: Thu, 14 Dec 2023 14:07:50 -0800 Subject: [PATCH] nogo: attempt to get test to pass on windows --- .bazelci/presubmit.yml | 1 + tests/core/nogo/coverage/coverage_cgo_test.go | 32 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 85b7fece71..21d270d32a 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -293,6 +293,7 @@ tasks: - "-//tests/core/go_proto_library_importmap:importmap_test" - "-//tests/core/go_test:data_test" - "-//tests/core/go_test:pwd_test" + - "-//tests/core/nogo/coverage:coverage_cgo_test.go" - "-//tests/core/nogo/coverage:coverage_test" - "-//tests/core/nogo/coverage:gen_code_test" - "-//tests/core/race:race_test" # fails on Windows due to upstream bug, see issue #2911 diff --git a/tests/core/nogo/coverage/coverage_cgo_test.go b/tests/core/nogo/coverage/coverage_cgo_test.go index 2fdf44044c..3458b2ea63 100644 --- a/tests/core/nogo/coverage/coverage_cgo_test.go +++ b/tests/core/nogo/coverage/coverage_cgo_test.go @@ -27,16 +27,16 @@ func TestMain(m *testing.M) { load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "nogo") go_library( - name = "foo", + name = "foo_cgo", cgo = True, - srcs = ["foo.go"], - importpath = "foo" + srcs = ["foo_cgo.go"], + importpath = "foo_cgo" ) go_test( - name = "foo_test", - srcs = ["foo_test.go"], - embed = [":foo"] + name = "foo_cgo_test", + srcs = ["foo_cgo_test.go"], + embed = [":foo_cgo"] ) nogo( @@ -44,22 +44,22 @@ nogo( deps = ["//noinit"], visibility = ["//visibility:public"], ) --- foo.go -- -package foo +-- foo_cgo.go -- +package foo_cgo import "C" -func Foo() string { - return "foo" +func FooCgo() string { + return "foo_cgo" } --- foo_test.go -- -package foo +-- foo_cgo_test.go -- +package foo_cgo import "testing" -func TestFoo(t *testing.T) { - if actual, expected := Foo(), "foo"; actual != expected { - t.Errorf("Foo() should return foo") +func TestFooCgo(t *testing.T) { + if actual, expected := FooCgo(), "foo_cgo"; actual != expected { + t.Errorf("FooCgo() should return foo_cgo") } } -- noinit/BUILD.bazel -- @@ -117,7 +117,7 @@ func run(pass *analysis.Pass) (interface{}, error) { } func TestNogoWithCoverageAndCgo(t *testing.T) { - if out, err := bazel_testing.BazelOutput("coverage", "//:foo_test"); err != nil { + if out, err := bazel_testing.BazelOutput("coverage", "//:foo_cgo_test"); err != nil { println(string(out)) t.Fatal(err) }