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