github.com/pingcap/tiup@v1.15.1/components/cluster/main_test.go (about) 1 // Copyright 2020 PingCAP, Inc. 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 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package main 15 16 import ( 17 "os" 18 "strings" 19 "testing" 20 ) 21 22 // To build: 23 // see build_integration_test in Makefile 24 // To run: 25 // tiup-cluster.test -test.coverprofile={file} __DEVEL--i-heard-you-like-tests 26 27 func TestMain(t *testing.T) { 28 var ( 29 args []string 30 run bool 31 ) 32 33 for _, arg := range os.Args { 34 switch { 35 case arg == "__DEVEL--i-heard-you-like-tests": 36 run = true 37 case strings.HasPrefix(arg, "-test"): 38 case strings.HasPrefix(arg, "__DEVEL"): 39 default: 40 args = append(args, arg) 41 } 42 } 43 os.Args = args 44 45 // fmt.Println(os.Args) 46 47 if run { 48 main() 49 } 50 }