1/* Copyright 2016 The Bazel Authors. All rights reserved. 2 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14*/ 15 16package lib_test 17 18import ( 19 "flag" 20 "os" 21 "testing" 22 23 "github.com/bazelbuild/rules_go/examples/lib" 24) 25 26var ( 27 buildTimeWant = flag.String("lib_test.buildtime", "", "expected value in TestBuildTime") 28 wasTestMainCalled = false 29) 30 31func TestLibraryPkgPath(t *testing.T) { 32 if got, want := lib.PkgPath(), "github.com/bazelbuild/rules_go/examples/lib"; got != want { 33 t.Errorf("lib.PkgPath() = %q; want %q", got, want) 34 } 35} 36 37func TestBuildTime(t *testing.T) { 38 if got, want := lib.BuildTime(), *buildTimeWant; got != want { 39 t.Errorf("buildTime = %q; want %q", got, want) 40 } 41} 42 43func TestMainCalled(t *testing.T) { 44 if !wasTestMainCalled { 45 t.Errorf("TestMain was not called") 46 } 47} 48 49func TestMain(m *testing.M) { 50 wasTestMainCalled = true 51 os.Exit(m.Run()) 52} 53