github.com/0xKiwi/rules_go@v0.24.3/tests/core/nogo/config/config_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 config_test 16 17 import ( 18 "testing" 19 20 "github.com/bazelbuild/rules_go/go/tools/bazel_testing" 21 ) 22 23 func TestMain(m *testing.M) { 24 bazel_testing.TestMain(m, bazel_testing.Args{ 25 Nogo: "@io_bazel_rules_go//:tools_nogo", 26 Main: ` 27 -- BUILD.bazel -- 28 load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 29 30 go_binary( 31 name = "shared_bin", 32 srcs = ["shared_bin.go"], 33 linkmode = "c-shared", 34 deps = [":shared_lib"], 35 ) 36 37 go_library( 38 name = "shared_lib", 39 srcs = ["shared_lib.go"], 40 importpath = "example.com/nogo/config/shared_lib", 41 ) 42 43 -- shared_bin.go -- 44 package main 45 46 import _ "example.com/nogo/config/shared_lib" 47 48 func main() { 49 } 50 51 -- shared_lib.go -- 52 package shared_lib 53 54 `, 55 }) 56 } 57 58 func TestShared(t *testing.T) { 59 if err := bazel_testing.RunBazel("build", "//:shared_bin"); err != nil { 60 t.Fatal(err) 61 } 62 }