1// Copyright 2019 The Bazel Authors. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package coverage_test 16 17import ( 18 "testing" 19 20 "github.com/bazelbuild/rules_go/go/tools/bazel_testing" 21) 22 23func TestMain(m *testing.M) { 24 bazel_testing.TestMain(m, bazel_testing.Args{ 25 Main: ` 26-- fx.go -- 27package fx 28 29import ( 30 _ "uber.com/internal" 31) 32-- fx_test.go -- 33package fx 34-- internal/BUILD.bazel -- 35load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 36 37go_library( 38 name = "go_default_library", 39 srcs = ["lib.go"], 40 importpath = "uber.com/internal", 41 visibility = ["//visibility:public"], 42 deps = ["@io_bazel_rules_go//go/tools/coverdata"], 43) 44 45go_test( 46 name = "go_default_test", 47 srcs = ["lib_test.go"], 48 embed = [":go_default_library"], 49) 50-- internal/lib.go -- 51package internal 52 53import _ "github.com/bazelbuild/rules_go/go/tools/coverdata" 54-- internal/lib_test.go -- 55package internal 56-- BUILD.bazel -- 57load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 58 59go_library( 60 name = "go_default_library", 61 srcs = ["fx.go"], 62 importpath = "code.uber.internal/devexp/code-coverage/cmd/fx", 63 visibility = ["//visibility:private"], 64 deps = ["//internal:go_default_library"], 65) 66 67go_test( 68 name = "go_default_test", 69 srcs = ["fx_test.go"], 70 embed = [":go_default_library"], 71) 72`, 73 }) 74} 75 76func TestIssue3017(t *testing.T) { 77 if err := bazel_testing.RunBazel("coverage", "//:go_default_test"); err != nil { 78 t.Fatal(err) 79 } 80} 81