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 no_prefix_test 16 17import ( 18 "testing" 19 20 "github.com/bazelbuild/rules_go/go/tools/bazel_testing" 21) 22 23const mainFiles = ` 24-- BUILD.bazel -- 25load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") 26 27go_library( 28 name = "go_default_library", 29 srcs = ["no_prefix.go"], 30 importpath = "github.com/bazelbuild/rules_go/tests/no_prefix", 31) 32 33go_test( 34 name = "go_default_xtest", 35 srcs = ["no_prefix_test.go"], 36 deps = [":go_default_library"], 37) 38 39go_binary( 40 name = "cmd", 41 srcs = ["cmd.go"], 42 deps = [":go_default_library"], 43) 44 45-- no_prefix.go -- 46package no_prefix 47 48-- no_prefix_test.go -- 49package no_prefix_test 50 51-- cmd.go -- 52package main 53 54import _ "github.com/bazelbuild/rules_go/tests/no_prefix" 55 56func main() { 57} 58` 59 60func TestMain(m *testing.M) { 61 bazel_testing.TestMain(m, bazel_testing.Args{ 62 Main: mainFiles, 63 }) 64} 65 66func TestBuild(t *testing.T) { 67 if err := bazel_testing.RunBazel("build", ":all"); err != nil { 68 t.Fatal(err) 69 } 70} 71