func main() { flag.Parse() if *showVersion { printversion() return } if *help { printhelp() return } if len(*url) == 0 { fmt.Println("must provide -silk.url") printhelp() return } root = "." args := flag.Args() if len(args) > 0 { root = args[0] } info, err := os.Stat(root) if err != nil { log.Fatalln(err) return } if info.IsDir() { // add default pattern root = filepath.Join(root, "*.silk.md") } testing.Main(func(pat, str string) (bool, error) { return true, nil }, []testing.InternalTest{{Name: "silk", F: testFunc}}, nil, nil) }
func main() { if len(os.Args) == 1 { cmd := exec.Command(os.Args[0], "-test.bench=.*", "-test.benchmem=true", "-test.benchtime=2s") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Run() return } fmt.Printf("Build: %s %s-%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) hashers := []struct { name string hash hash.Hash }{ {"SHA256", sha256.New()}, {"SHAKE256", shakeAdapter{sha3.NewShake256(), 64}}, } benchmarks := []testing.InternalBenchmark{} for _, h := range hashers { benchmarks = append(benchmarks, testing.InternalBenchmark{ Name: h.name, F: wrap(h.hash), }) } testing.Main(func(pat, str string) (bool, error) { return true, nil }, nil, benchmarks, nil) }
func main() { flag.StringVar(&target, "target", "localhost:8080", "Test target") flag.StringVar(&authUser, "user", "", "Username") flag.StringVar(&authPass, "pass", "", "Password") flag.StringVar(&csrfFile, "csrf", "", "CSRF token file") flag.StringVar(&apiKey, "api", "", "API key") flag.Parse() if len(csrfFile) > 0 { fd, err := os.Open(csrfFile) if err != nil { log.Fatal(err) } s := bufio.NewScanner(fd) for s.Scan() { csrfToken = s.Text() } fd.Close() } var tests []testing.InternalTest tests = append(tests, testing.InternalTest{"TestGetIndex", TestGetIndex}) tests = append(tests, testing.InternalTest{"TestGetVersion", TestGetVersion}) tests = append(tests, testing.InternalTest{"TestGetVersionNoCSRF", TestGetVersion}) tests = append(tests, testing.InternalTest{"TestJSONEndpoints", TestJSONEndpoints}) if len(authUser) > 0 || len(apiKey) > 0 { tests = append(tests, testing.InternalTest{"TestJSONEndpointsNoAuth", TestJSONEndpointsNoAuth}) tests = append(tests, testing.InternalTest{"TestJSONEndpointsIncorrectAuth", TestJSONEndpointsIncorrectAuth}) } if len(csrfToken) > 0 { tests = append(tests, testing.InternalTest{"TestJSONEndpointsNoCSRF", TestJSONEndpointsNoCSRF}) } testing.Main(matcher, tests, nil, nil) }
func main() { testing.Main([]testing.Test{ testing.Test{"String", golambda.TestString}, testing.Test{"Parse", golambda.TestParse}, testing.Test{"OccursFree", golambda.TestOccursFree}, testing.Test{"Substitute", golambda.TestSubstitute}, testing.Test{"Reduce", golambda.TestReduce} }); }
func main() { flag.Set("test.bench", "Large") flag.Set("test.v", "true") testing.Main(func(pat, str string) (bool, error) { return true, nil }, []testing.InternalTest{{"TestLargeMapGC", TestLargeMapGC}}, []testing.InternalBenchmark{{"BenchmarkLargeMapGC", BenchmarkLargeMapGC}}, []testing.InternalExample{}) }
func main() { log.Println(runtime.Version()) flag.Set("test.bench", "foo") flag.Set("test.v", "true") testing.Main(func(pat, str string) (bool, error) { return true, nil }, []testing.InternalTest{{"TestSlice", TestSlice}, {"TestSliceByte", TestSliceByte}}, []testing.InternalBenchmark{}, []testing.InternalExample{}) }
func TestCustomSuite(path string) { test := func(t *testing.T) { RunTestSuite(path, t) } tests := []testing.InternalTest{testing.InternalTest{Name: "CustomTest(" + path + ")", F: test}} _, benches, examples := initialize() testing.Main(matchString, tests, benches, examples) }
func main() { log.Println(runtime.Version()) flag.Set("test.bench", "foo") flag.Set("test.v", "true") testing.Main(func(pat, str string) (bool, error) { return true, nil }, []testing.InternalTest{}, []testing.InternalBenchmark{{"BenchmarkFreelist", BenchmarkFreelist}, {"BenchmarkFreelist2", BenchmarkFreelist2}}, []testing.InternalExample{}) }
func main() { testsuite := komoku.Testsuite() numTests := len(testsuite) if numTests > 1 || numTests == 0 { fmt.Printf("Running %d tests in SUBSTITUTE_THIS...\n", numTests) } else { fmt.Printf("Running %d test in SUBSTITUTE_THIS...\n", numTests) } matchAlways := func(pat, str string) (bool, os.Error) { return true, nil } testing.Main(matchAlways, testsuite) }
func main() { flag.Parse() if *g_keyId == "" { fmt.Println("You must set the -key_id flag.") fmt.Println("Find a key ID here:") fmt.Println(" https://portal.aws.amazon.com/gp/aws/securityCredentials") os.Exit(1) } if *g_bucketName == "" { fmt.Println("You must set the -bucket flag.") fmt.Println("Manage your buckets here:") fmt.Println(" https://console.aws.amazon.com/s3/") os.Exit(1) } if *g_region == "" { fmt.Println("You must set the -region flag. See region.go.") os.Exit(1) } // Read in the access key. g_accessKey.Id = *g_keyId g_accessKey.Secret = readPassword("Access key secret: ") // Run the tests. matchString := func(pat, str string) (bool, error) { re, err := regexp.Compile(pat) if err != nil { return false, err } return re.MatchString(str), nil } testing.Main( matchString, []testing.InternalTest{ testing.InternalTest{ Name: "IntegrationTest", F: func(t *testing.T) { ogletest.RunTests(t) }, }, }, []testing.InternalBenchmark{}, []testing.InternalExample{}, ) }
func main() { flag.Parse() test := []testing.InternalTest{ {"Get", add.Get}, {"PostEmpty", add.PostEmpty}, {"PostFile", add.PostFile}, {"GetCat", cat.Get}, } bench := []testing.InternalBenchmark{} examples := []testing.InternalExample{} testing.Main(strmatch, test, bench, examples) }
func BenchmarkCustomSuite(path string) { benchmark := func(b *testing.B) { RunBenchmarkSuite(path, b) } benches := []testing.InternalBenchmark{testing.InternalBenchmark{Name: "CustomBenchmark(" + path + ")", F: benchmark}} test := func(t *testing.T) { RunTestSuite(path, t) } tests := []testing.InternalTest{testing.InternalTest{Name: "CustomTest(" + path + ")", F: test}} _, _, examples := initialize() flag.Set("test.bench", ".*") // IMPORTANT : The testing internals check that this flag is set testing.Main(matchString, tests, benches, examples) }
func main() { flag.Parse() if *showVersion { printversion() return } if *help { printhelp() return } if *url == "" { fmt.Println("silk.url argument is required") return } paths = flag.Args() testing.Main(func(pat, str string) (bool, error) { return true, nil }, []testing.InternalTest{{Name: "silk", F: testFunc}}, nil, nil) }
func main() { flag.StringVar(&target, "target", "localhost:8080", "Test target") flag.StringVar(&authUser, "user", "", "Username") flag.StringVar(&authPass, "pass", "", "Password") flag.StringVar(&csrfFile, "csrf", "", "CSRF token file") flag.StringVar(&apiKey, "api", "", "API key") flag.Parse() if len(csrfFile) > 0 { fd, err := os.Open(csrfFile) if err != nil { log.Fatal(err) } s := bufio.NewScanner(fd) for s.Scan() { csrfToken = s.Text() } fd.Close() } var tests []testing.InternalTest tests = append(tests, testing.InternalTest{"TestGetIndex", TestGetIndex}) tests = append(tests, testing.InternalTest{"TestJSONEndpoints", TestJSONEndpoints}) tests = append(tests, testing.InternalTest{"TestPOSTNoCSRF", TestPOSTNoCSRF}) if len(authUser) > 0 { // If we expect authentication, verify that it fails with the wrong password and wrong API key tests = append(tests, testing.InternalTest{"TestJSONEndpointsNoAuth", TestJSONEndpointsNoAuth}) tests = append(tests, testing.InternalTest{"TestJSONEndpointsIncorrectAuth", TestJSONEndpointsIncorrectAuth}) } if len(csrfToken) > 0 { // If we have a CSRF token, verify that POST succeeds with it tests = append(tests, testing.InternalTest{"TestPostWitchCSRF", TestPostWitchCSRF}) tests = append(tests, testing.InternalTest{"TestGetPostConfigOK", TestGetPostConfigOK}) tests = append(tests, testing.InternalTest{"TestGetPostConfigFail", TestGetPostConfigFail}) } fmt.Printf("Testing HTTP: CSRF=%v, API=%v, Auth=%v\n", len(csrfToken) > 0, len(apiKey) > 0, len(authUser) > 0) testing.Main(matcher, tests, nil, nil) }
func main() { var tests []testing.InternalTest tests = append(tests, testing.InternalTest{Name: "TestAll", F: TestAll}) testing.Main(func(pat, str string) (bool, error) { return true, nil }, tests, nil, nil) }
func main() { testing.Main(__regexp__.MatchString, tests) testing.RunBenchmarks(__regexp__.MatchString, benchmarks) }
func main() { tests := []testing.InternalTest{{"TestGo", TestGo}} matchAll := func(t string, pat string) (bool, error) { return true, nil } testing.Main(matchAll, tests, nil, nil) }
func main() { testing.Main(regexp.MatchString, tests) }
func main() { testing.Main(func(string, string) (bool, error) { return true, nil }, tests, benchmarks, []testing.InternalExample{}) }
func main() { testing.Main(matchString, tests, benchmarks) }
func main() { testing.Main(tests) testing.RunBenchmarks(benchmarks) }