示例#1
0
文件: main.go 项目: lucmichalski/silk
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)
}
示例#2
0
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)
}
示例#3
0
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)
}
示例#4
0
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{})
}
示例#7
0
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{})
}
示例#9
0
文件: skeleton.go 项目: Sh4pe/komoku
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)
}
示例#10
0
文件: main.go 项目: jacobsa/aws
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{},
	)
}
示例#11
0
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)
}
示例#12
0
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)
}
示例#13
0
文件: main.go 项目: matryer/silk
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)
}
示例#14
0
文件: http.go 项目: GDXN/syncthing
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)
}
示例#15
0
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)
}
示例#16
0
func main() {
	testing.Main(__regexp__.MatchString, tests)
	testing.RunBenchmarks(__regexp__.MatchString, benchmarks)
}
示例#17
0
文件: debug.go 项目: kego/ke
func main() {
	tests := []testing.InternalTest{{"TestGo", TestGo}}
	matchAll := func(t string, pat string) (bool, error) { return true, nil }
	testing.Main(matchAll, tests, nil, nil)
}
示例#18
0
func main() {
	testing.Main(regexp.MatchString, tests)
}
示例#19
0
文件: ddb.go 项目: ishii0514/ddb
func main() {
	testing.Main(func(string, string) (bool, error) { return true, nil },
		tests,
		benchmarks,
		[]testing.InternalExample{})
}
示例#20
0
func main() {
	testing.Main(matchString, tests, benchmarks)
}
示例#21
0
func main() {
	testing.Main(tests)
	testing.RunBenchmarks(benchmarks)
}