diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 5426644fdf..adb44c4bea 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -226,7 +226,6 @@ platforms: - "-//tests/legacy/proto_ignore_go_package_option:b_go_proto" - "-//tests/legacy/proto_ignore_go_package_option:b_proto" - "-//tests/legacy/test_chdir:go_default_test" - - "-//tests/legacy/test_filter_test:test_filter_test" - "-//tests/legacy/test_rundir:go_default_test" - "-//tests/legacy/transitive_data:go_default_test" - "-//tests/reproducibility:go_default_test" @@ -321,7 +320,6 @@ platforms: - "-//tests/legacy/go_embed_data:embedded_tar" - "-//tests/legacy/info:info" - "-//tests/legacy/test_chdir:go_default_test" - - "-//tests/legacy/test_filter_test:test_filter_test" - "-//tests/legacy/test_rundir:go_default_test" - "-//tests/legacy/transitive_data:go_default_test" - "-//tests/reproducibility:go_default_test" diff --git a/tests/core/go_test/BUILD.bazel b/tests/core/go_test/BUILD.bazel index f0edc37c19..a56800a10d 100644 --- a/tests/core/go_test/BUILD.bazel +++ b/tests/core/go_test/BUILD.bazel @@ -1,4 +1,5 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test") test_suite( name = "go_test", @@ -137,3 +138,8 @@ go_library( data = ["z"], importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/data_test_dep", ) + +go_bazel_test( + name = "test_filter_test", + srcs = ["test_filter_test.go"], +) diff --git a/tests/core/go_test/README.rst b/tests/core/go_test/README.rst index abcfcc137f..28dc6cb9a6 100644 --- a/tests/core/go_test/README.rst +++ b/tests/core/go_test/README.rst @@ -71,3 +71,8 @@ data_test Checks that data dependencies, including those inherited from ``deps`` and ``embed``, are visible to tests at run-time. Source files should not be visible at run-time. + +test_filter_test +---------------- + +Checks that ``--test_filter`` actually filters out test cases. diff --git a/tests/core/go_test/test_filter_test.go b/tests/core/go_test/test_filter_test.go new file mode 100644 index 0000000000..49b1ce734d --- /dev/null +++ b/tests/core/go_test/test_filter_test.go @@ -0,0 +1,54 @@ +// Copyright 2019 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package test_filter_test + +import ( + "testing" + + "github.com/bazelbuild/rules_go/go/tools/bazel_testing" +) + +func TestMain(m *testing.M) { + bazel_testing.TestMain(m, bazel_testing.Args{ + Main: ` +-- BUILD.bazel -- +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +go_test( + name = "filter_test", + srcs = ["filter_test.go"], +) + +-- filter_test.go -- +package test_filter + +import "testing" + +func TestShouldPass(t *testing.T) { +} + +func TestShouldFail(t *testing.T) { + t.Fail() +} + +`, + }) +} + +func Test(t *testing.T) { + if err := bazel_testing.RunBazel("test", "//:filter_test", "--test_filter=Pass"); err != nil { + t.Fatal(err) + } +} diff --git a/tests/legacy/test_filter_test/BUILD.bazel b/tests/legacy/test_filter_test/BUILD.bazel deleted file mode 100644 index 3ef96bc1a7..0000000000 --- a/tests/legacy/test_filter_test/BUILD.bazel +++ /dev/null @@ -1,16 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_test") -load("@io_bazel_rules_go//tests:bazel_tests.bzl", "bazel_test") - -go_test( - name = "go_default_test", - size = "small", - srcs = ["test_filter_test.go"], - tags = ["manual"], -) - -bazel_test( - name = "test_filter_test", - args = ["--test_filter=Pass"], - command = "test", - targets = [":go_default_test"], -) diff --git a/tests/legacy/test_filter_test/test_filter_test.go b/tests/legacy/test_filter_test/test_filter_test.go deleted file mode 100644 index 9e31f3e894..0000000000 --- a/tests/legacy/test_filter_test/test_filter_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package test_filter - -import "testing" - -func TestShouldPass(t *testing.T) { -} - -func TestShouldFail(t *testing.T) { - t.Fail() -}