Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate legacy test to //tests/core/go_test:test_filter_test #2298

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions tests/core/go_test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"],
)
5 changes: 5 additions & 0 deletions tests/core/go_test/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
54 changes: 54 additions & 0 deletions tests/core/go_test/test_filter_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
16 changes: 0 additions & 16 deletions tests/legacy/test_filter_test/BUILD.bazel

This file was deleted.

10 changes: 0 additions & 10 deletions tests/legacy/test_filter_test/test_filter_test.go

This file was deleted.