当前位置: 首页>>代码示例>>Golang>>正文


Golang testing.Verbose函数代码示例

本文整理汇总了Golang中testing.Verbose函数的典型用法代码示例。如果您正苦于以下问题:Golang Verbose函数的具体用法?Golang Verbose怎么用?Golang Verbose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Verbose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestTreePush

func TestTreePush(t *testing.T) {
	db, fn := mkrtest(t, rtdir)
	defer fn()
	db.Close()
	db, fn2 := mktest(t, tdir)
	defer fn2()
	db.Close()

	tr, err := New("adb", tdir, "unix!local!9988!/p")
	if err != nil {
		t.Fatalf("tree %s", err)
	}
	tr.Debug = testing.Verbose()
	tr.Rdb.Debug = testing.Verbose()
	defer tr.Close()
	fstest.MkChgs(t, tdir)
	fstest.MkChgs2(t, rtdir+"/p")
	chkFiles(t, tr.Ldb, fstest.AllFiles, fstest.AllFilesList)
	chkFiles(t, tr.Rdb, fstest.AllFiles, fstest.AllFilesList)
	dprintf("\npush\n")
	cc, dc := getChgs()
	err = tr.BlindPush(cc)
	if err != nil {
		t.Fatalf("push %s", err)
	}
	cs := <-dc
	logChgs(cs)
	cmpChgs(t, pushcs, cs)
	chkFiles(t, tr.Ldb, nil, pushldb)
	chkFiles(t, tr.Rdb, nil, pushrdb)
	os.RemoveAll(rtdir + ".push")
	os.Rename(rtdir+"/p", rtdir+".push")
}
开发者ID:fjballest,项目名称:clive,代码行数:33,代码来源:repl_test.go

示例2: TestExtChanges

func TestExtChanges(t *testing.T) {
	os.Args[0] = "rzx.test"
	fstest.Verb = testing.Verbose()
	ccfg, err := net.TLSCfg("/Users/nemo/.ssh/client")
	if err != nil {
		t.Logf("no certs found, no tls conn")
	}
	scfg, err := net.TLSCfg("/Users/nemo/.ssh/server")
	if err != nil || ccfg == nil {
		ccfg = nil
		scfg = nil
		t.Logf("no certs found, no tls conn")
	}
	_, _ = scfg, ccfg
	fstest.MkTree(t, tdir)
	defer os.RemoveAll(tdir)
	lfs, err := zux.NewZX(tdir)
	if err != nil {
		t.Fatal(err)
	}
	defer lfs.Sync()

	cfs, err := New(lfs)
	if err != nil {
		t.Fatal(err)
	}
	defer cfs.Close()
	cfs.Debug = testing.Verbose()
	lfs.Debug = testing.Verbose()
	cfs.Flags.Set("rfsdebug", cfs.Debug)
	cfs.Flags.Set("cachedebug", cfs.Debug)
	cfs.Flags.Set("verb", cfs.Debug)
	rc := fscmp.Diff(lfs, cfs)
	out := ""
	for c := range rc {
		s := fmt.Sprintf("pre chg %s %s\n", c.Type, c.D.Fmt())
		out += s
	}
	if len(out) > 0 {
		t.Fatalf("had changes")
	}
	cfs.Dprintf("%s", out)
	fstest.MkZXChgs(t, lfs)
	fstest.MkZXChgs2(t, lfs)
	cacheTout = time.Millisecond
	time.Sleep(cacheTout)
	rc = fscmp.Diff(lfs, cfs)
	out = ""
	for c := range rc {
		s := fmt.Sprintf("post chg %s %s\n", c.Type, c.D.Fmt())
		out += s
	}
	cfs.Dprintf("%s", out)
	if len(out) > 0 {
		t.Fatalf("had missed external changes")
	}
	if cfs.Debug {
		cfs.c.dump()
	}
}
开发者ID:chengguozhen,项目名称:clive,代码行数:60,代码来源:zxc_test.go

示例3: TestTreeSync

func TestTreeSync(t *testing.T) {
	db, fn := mkrtest(t, rtdir)
	defer fn()
	db.Close()
	db, fn2 := mktest(t, tdir)
	defer fn2()
	db.Close()

	tr, err := New("adb", tdir, "unix!local!9988!/p")
	if err != nil {
		t.Fatalf("tree %s", err)
	}
	tr.Debug = testing.Verbose()
	tr.Rdb.Debug = testing.Verbose()
	defer tr.Close()
	fstest.MkChgs(t, tdir)
	fstest.MkChgs2(t, rtdir+"/p")
	dprintf("\nsync\n")
	cc, dc := getChgs()
	err = tr.Sync(cc)
	if err != nil {
		t.Fatalf("sync %s", err)
	}
	cs := <-dc
	logChgs(cs)
	chkFiles(t, tr.Ldb, nil, "")
	chkFiles(t, tr.Rdb, nil, "")
	os.RemoveAll(tdir + ".pull")
	os.Rename(tdir, tdir+".pull")
	os.RemoveAll(rtdir + ".push")
	os.Rename(rtdir+"/p", rtdir+".push")
}
开发者ID:fjballest,项目名称:clive,代码行数:32,代码来源:repl_test.go

示例4: TestExecBack

func TestExecBack(t *testing.T) {
	// Debug = testing.Verbose()
	for i, e := range xexprs {
		p, err := CompileStr(e, Bck)
		if err != nil {
			t.Errorf("compile error: %v", err)
			continue
		}
		fmt.Printf("expr: '%s':\n", e)
		if testing.Verbose() && false {
			fmt.Printf("%s", p)
		}
		ranges := [][]Range{}
		for pos := len(xtext); pos >= 0; {
			rg := p.ExecStr(xtext, pos, len(xtext))
			if len(rg)==0 || rg[0].P0<0 {
				break
			}
			pos = rg[0].P0
			if rg[0].P0 == rg[0].P1 {
				pos--
			}
			o := fmt.Sprintf("%v", rg)
			txt := xtext[rg[0].P0:rg[0].P1]
			if testing.Verbose() {
				fmt.Printf(" =>%s '%s'\n", o, txt)
			}
			ranges = append(ranges, rg)
		}
		os := fmt.Sprintf("%v", ranges)
		if os != xoutback[i] {
			t.Errorf("output for %s does not match: `%s`", e, os)
		}
	}
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:35,代码来源:sre_test.go

示例5: NewConfig

// NewConfig returns the default config with temporary paths.
func NewConfig() *run.Config {
	c := run.NewConfig()
	c.ReportingDisabled = true
	c.Cluster.ShardWriterTimeout = toml.Duration(30 * time.Second)
	c.Cluster.WriteTimeout = toml.Duration(30 * time.Second)
	c.Meta.Dir = MustTempFile()
	c.Meta.BindAddress = "127.0.0.1:0"
	c.Meta.HTTPBindAddress = "127.0.0.1:0"
	c.Meta.HeartbeatTimeout = toml.Duration(50 * time.Millisecond)
	c.Meta.ElectionTimeout = toml.Duration(50 * time.Millisecond)
	c.Meta.LeaderLeaseTimeout = toml.Duration(50 * time.Millisecond)
	c.Meta.CommitTimeout = toml.Duration(5 * time.Millisecond)

	if !testing.Verbose() {
		c.Meta.LoggingEnabled = false
	}

	c.Data.Dir = MustTempFile()
	c.Data.WALDir = MustTempFile()
	c.Data.WALLoggingEnabled = false

	c.HintedHandoff.Dir = MustTempFile()

	c.HTTPD.Enabled = true
	c.HTTPD.BindAddress = "127.0.0.1:0"
	c.HTTPD.LogEnabled = testing.Verbose()

	c.Monitor.StoreEnabled = false

	return c
}
开发者ID:rwarren,项目名称:influxdb,代码行数:32,代码来源:server_helpers_test.go

示例6: init

func init() {
	// a 'live' test against the Twilio API
	if os.Getenv("TWILIO_TEST_CONFIG") != "" {
		if testing.Verbose() {
			fmt.Fprintf(os.Stderr, "TWILIO_TEST_CONFIG=%s\n", os.Getenv("TWILIO_TEST_CONFIG"))
		}
		data, e := ioutil.ReadFile(os.Getenv("TWILIO_TEST_CONFIG"))
		if e != nil {
			fmt.Fprintf(os.Stderr, "File error: %v\n", e)
		}
		if testing.Verbose() {
			fmt.Fprintf(os.Stderr, "twilio_test.go: init, data=%s\n", string(data))
		}
		DefaultClient.Unmarshal(data)
		DefaultClient.Verbose = testing.Verbose()
		if testing.Verbose() {
			fmt.Fprintf(os.Stderr, "twilio_test.go: init, DefaultClient=%s\n", DefaultClient)
		}
	} else {
		if testing.Verbose() {
			fmt.Fprintf(os.Stderr, "init: Creating default\n")
		}
		TestServer = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			fmt.Fprintf(w, "%s", `{"sid": "account.test-sid"}`)
		}))
		// how to close this at the end of all the tests?
		// defer TestServer.Close()
		TestBaseUrl = TestServer.URL
		DefaultClient = MakeTestClient("banana", "kimchee")
	}
}
开发者ID:kyleburton,项目名称:twilio.go,代码行数:31,代码来源:twilio_test.go

示例7: TestResolve

func TestResolve(t *testing.T) {
	ns := mkns(t, false)
	defer fstest.RmTree(t, tdir)
	ns.Debug = testing.Verbose()
	ns.DebugFind = testing.Verbose()

	for _, r := range resolves {
		_, dirs, paths, err := ns.Resolve(r.Path)
		printf("sts %v\n", err)
		if err!=nil && !r.Fails {
			t.Fatalf("failed with %v", err)
		}
		if err==nil && r.Fails {
			t.Fatal("didn't fail")
		}
		if len(dirs) != len(paths) {
			t.Fatal("wrong lengths")
		}
		printf("dirs:\n")
		for _, d := range dirs {
			delete(d, "Uid")
			delete(d, "Gid")
			delete(d, "Wuid")
			delete(d, "Sum")
			printf("\t`%s`,\n", d)
		}
		printf("paths:\n")
		for _, p := range paths {
			printf("\t`%s`,\n", p)
		}
		for i := 0; i<len(r.Dirs) && i<len(dirs); i++ {
			if r.Dirs[i] != dirs[i].String() {
				t.Fatalf("bad result [%d]\n\tgot %s\n\twant %s\n",
					i, dirs[i], r.Dirs[i])
			}
		}
		if r.Dirs != nil {
			if len(dirs) > len(r.Dirs) {
				t.Fatalf("unexpected %s", dirs[len(r.Dirs)])
			}
			if len(dirs) < len(r.Dirs) {
				t.Fatalf("did expect %s", r.Dirs[len(dirs)])
			}
		}
		for i := 0; i<len(r.Paths) && i<len(paths); i++ {
			if r.Paths[i] != paths[i] {
				t.Fatalf("bad result [%d]\n\tgot %s\n\twant %s\n",
					i, paths[i], r.Paths[i])
			}
		}
		if r.Paths != nil {
			if len(paths) > len(r.Paths) {
				t.Fatalf("unexpected %s", paths[len(r.Paths)])
			}
			if len(paths) < len(r.Paths) {
				t.Fatalf("did expect %s", r.Paths[len(paths)])
			}
		}
	}
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:60,代码来源:ns_test.go

示例8: testWorldDat

func testWorldDat(t *testing.T, fn string) {
	t.Log(fn)

	f, err := os.Open(fn)
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()

	r := &Reader{f}

	var w WorldDat

	err = r.Decode(&w)
	if err != nil {
		t.Error(err)
	}
	if testing.Verbose() {
		t.Log(string(prettyPrint(&w, reflect.ValueOf(w), nil, []byte{'\n'}, "")))
	}

	if err == nil || testing.Verbose() {
		xxd := exec.Command("xxd")
		xxd.Stdin = io.LimitReader(r, 1<<10)
		b, err := xxd.CombinedOutput()
		if err != nil {
			t.Fatal(err)
		}
		if len(b) != 0 {
			t.Errorf("Unparsed data:\n%s", b)
		}
	}
}
开发者ID:BenLubar,项目名称:df2014,代码行数:33,代码来源:world_dat_test.go

示例9: tempHfile

func tempHfile(t *testing.T, compress bool, blockSize int, keys [][]byte, values [][]byte) (string, *Scanner) {
	fp, err := ioutil.TempFile("", "demohfile")
	if err != nil {
		t.Fatal("error creating tempfile:", err)
	}
	if testing.Verbose() {
		log.Println("###############")
		log.Println("Writing temp hfile:", fp.Name())
		log.Println("###############")
	}
	w, err := NewWriter(fp, compress, blockSize, testing.Verbose())
	if err != nil {
		t.Fatal("error creating writer:", err)
	}
	for i, _ := range keys {
		if err := w.Write(keys[i], values[i]); err != nil {
			t.Fatal("error writing k-v pair:", err)
		}
	}
	w.Close()

	if testing.Verbose() {
		log.Println("###############")
		log.Println("Done writing temp hfile:", fp.Name())
		log.Println("###############")
	}

	r, err := NewReader("demo", fp.Name(), false, testing.Verbose())
	if err != nil {
		t.Fatal("error creating reader:", err)
	}
	s := NewScanner(r)

	return fp.Name(), s
}
开发者ID:dt,项目名称:gohfile,代码行数:35,代码来源:writer_test.go

示例10: TestRFind

func TestRFind(t *testing.T) {
	ns := mkrns(t, false)
	defer fstest.RmTree(t, tdir)
	ns.Debug = testing.Verbose()
	ns.DebugFind = testing.Verbose()
	for _, f := range finds {
		dc := ns.Find(f.Path, f.Pred, f.Spref, f.Spref, f.Depth)
		outs := []string{}
		for d := range dc {
			printf("got %s err %s\n", d.TestFmt(), d["err"])
			if d["err"] != "" {
				continue
			}
			if d["type"] == "c" {		// for fuse&cfs
				d["type"] = "-"
			}
			outs = append(outs, d.TestFmt())
		}
		printf("done find %s %s sts %v\n", f.Path, f.Pred, cerror(dc))
		for i := 0; i<len(f.Res) && i<len(outs); i++ {
			if outs[i] != f.Res[i] {
				t.Fatalf("bad result [%d]\n\tgot %s\n\twant %s\n", i, outs[i], f.Res[i])
			}
		}
		if f.Res != nil {
			if len(outs) > len(f.Res) {
				t.Fatalf("unexpected %s", outs[len(f.Res)])
			}
			if len(outs) < len(f.Res) {
				t.Fatalf("unexpected %s", f.Res[len(outs)])
			}
		}
	}
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:34,代码来源:ns_test.go

示例11: TestInit

// Test -init flag
func TestInit(t *testing.T) {
	dir := tmpDir + "TestInit/"
	err := os.Mkdir(dir, 0777)
	if err != nil {
		t.Fatal(err)
	}
	cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test", "-scryptn=10", dir)
	if testing.Verbose() {
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
	}
	err = cmd.Run()
	if err != nil {
		t.Fatal(err)
	}
	_, err = os.Stat(dir + cryptfs.ConfDefaultName)
	if err != nil {
		t.Fatal(err)
	}

	// Test -passwd
	cmd2 := exec.Command(gocryptfsBinary, "-passwd", "-extpass", "echo test", dir)
	if testing.Verbose() {
		cmd2.Stdout = os.Stdout
		cmd2.Stderr = os.Stderr
	}
	err = cmd2.Run()
	if err != nil {
		t.Error(err)
	}
}
开发者ID:thinkingo,项目名称:gocryptfs,代码行数:32,代码来源:cli_test.go

示例12: TestMessageValidity

// Reads all message fixtures from fixtures/ein and validates them
// against the master message schema (schema.json).
func TestMessageValidity(t *testing.T) {
	files, err := ioutil.ReadDir("../fixtures/ein/")
	if err != nil {
		t.Error("Failed to scan message fixtures dir:", err.Error())
		t.FailNow()
	}

	for _, f := range files {
		if testing.Verbose() {
			t.Log("Beginning validation on", f.Name())
		}

		src, _ := ioutil.ReadFile("../fixtures/ein/" + f.Name())
		msg := gjs.NewStringLoader(string(src))
		result, err := masterSchema.Validate(msg)

		if err != nil {
			panic(err.Error())
		}

		if result.Valid() {
			if testing.Verbose() {
				t.Log(f.Name(), "passed validation")
			}
		} else {
			for _, desc := range result.Errors() {
				t.Errorf("%s\n", strings.Replace(desc.String(), "root", f.Name(), 1))
			}
		}
	}
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:33,代码来源:interpret_test.go

示例13: goCmd

// goCmd invokes the go tool with the installsuffix set up by TestMain. It calls
// t.Errorf if the command fails.
func goCmd(t *testing.T, args ...string) {
	newargs := []string{args[0], "-installsuffix=" + suffix}
	if testing.Verbose() {
		newargs = append(newargs, "-v")
	}
	newargs = append(newargs, args[1:]...)
	c := exec.Command("go", newargs...)
	var output []byte
	var err error
	if testing.Verbose() {
		fmt.Printf("+ go %s\n", strings.Join(newargs, " "))
		c.Stdout = os.Stdout
		c.Stderr = os.Stderr
		err = c.Run()
	} else {
		output, err = c.CombinedOutput()
	}
	if err != nil {
		if t != nil {
			t.Errorf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, output)
		} else {
			log.Fatalf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, output)
		}
	}
}
开发者ID:danny8002,项目名称:go,代码行数:27,代码来源:shared_test.go

示例14: TestID

func TestID(t *testing.T) {
	id, err := NextSystemUID()
	if err != nil {
		t.Error(err)
	}
	if testing.Verbose() {
		fmt.Print(" Next system UID: ", id)
	}

	if id, err = NextUID(); err != nil {
		t.Error(err)
	}
	if testing.Verbose() {
		fmt.Println("\tNext UID:", id)
	}

	if id, err = NextSystemGID(); err != nil {
		t.Error(err)
	}
	if testing.Verbose() {
		fmt.Print(" Next system GID: ", id)
	}

	if id, err = NextGID(); err != nil {
		t.Error(err)
	}
	if testing.Verbose() {
		fmt.Println("\tNext GID:", id)
	}
}
开发者ID:ahmetalpbalkan,项目名称:osutil,代码行数:30,代码来源:id_test.go

示例15: testfn

func testfn(t *testing.T, fns ...func(t fstest.Fataler, fss ...zx.Tree)) {
	bufs.Size = 1 * 1024
	os.RemoveAll(tlfsdir)
	defer os.RemoveAll(tlfsdir)
	if err := os.Mkdir(tlfsdir, 0755); err != nil {
		t.Fatalf("lfs: %s", err)
	}
	os.Args[0] = "mdfs_test"
	dfs, err := lfs.New("	cache", tlfsdir, lfs.RW)
	if err != nil {
		t.Fatalf("lfs: %s", err)
	}
	dfs.SaveAttrs(true)
	mfs, err := New("example mfs", dfs)
	if err != nil {
		t.Fatalf("lfs: %s", err)
	}
	xfs, _ := mfs.AuthFor(&auth.Info{Uid: dbg.Usr, SpeaksFor: dbg.Usr, Ok: true})
	fs := xfs.(zx.RWTree)
	fstest.MkZXTree(t, fs)
	mfs.Dbg = testing.Verbose()
	dfs.Dbg = testing.Verbose()
	var fn func(t fstest.Fataler, fss ...zx.Tree)
	if len(fns) > 0 {
		fn = fns[0]
	}
	if fn != nil {
		if mfs.Dbg {
			defer func() {
				mfs.Dump(os.Stdout)
				dfs.Dump(os.Stdout)
			}()
		}
		for _, fn := range fns {
			fn(t, fs)
		}
	} else {
		d1, _ := zx.Stat(mfs, "/")
		printf("mfs st:\t%s\n", d1)
		d1, _ = zx.Stat(dfs, "/")
		printf("lfs st:\t%s\n", d1)
		// recreate, to test a reload
		mfs, err = New("example mfs", dfs)
		if err != nil {
			t.Fatalf("lfs: %s", err)
		}
		mfs.Dbg = testing.Verbose()
		xfs, _ = mfs.AuthFor(&auth.Info{Uid: dbg.Usr, SpeaksFor: dbg.Usr, Ok: true})
		fs = xfs.(zx.RWTree)
		if mfs.Dbg {
			defer func() {
				mfs.Dump(os.Stdout)
				dfs.Dump(os.Stdout)
			}()
		}
	}
	mfs.Dbg = false
	dfs.Dbg = false
	fstest.SameDump(t, mfs, dfs)
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:60,代码来源:mdfs_test.go


注:本文中的testing.Verbose函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。