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


Golang testutil.FatalOnErrT函数代码示例

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


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

示例1: Construct

func (tbl *testTable) Construct(t *testing.T) xrefs.Service {
	p := make(testProtoTable)
	tickets := stringset.New()
	for _, n := range tbl.Nodes {
		tickets.Add(n.Ticket)
	}
	for _, es := range tbl.EdgeSets {
		tickets.Remove(es.EdgeSet.Source.Ticket)
		testutil.FatalOnErrT(t, "Error writing edge set: %v", p.Put(ctx, EdgeSetKey(mustFix(t, es.EdgeSet.Source.Ticket)), es))
	}
	// Fill in EdgeSets for zero-degree nodes
	for ticket := range tickets {
		es := &srvpb.PagedEdgeSet{
			EdgeSet: &srvpb.EdgeSet{
				Source: getNode(ticket),
			},
		}
		testutil.FatalOnErrT(t, "Error writing edge set: %v", p.Put(ctx, EdgeSetKey(mustFix(t, es.EdgeSet.Source.Ticket)), es))
	}
	for _, ep := range tbl.EdgePages {
		testutil.FatalOnErrT(t, "Error writing edge page: %v", p.Put(ctx, []byte(edgePagesTablePrefix+ep.PageKey), ep))
	}
	for _, d := range tbl.Decorations {
		testutil.FatalOnErrT(t, "Error writing file decorations: %v", p.Put(ctx, DecorationsKey(mustFix(t, d.FileTicket)), d))
	}
	return NewCombinedTable(table.ProtoBatchParallel{p})
}
开发者ID:baev,项目名称:kythe,代码行数:27,代码来源:xrefs_test.go

示例2: TestAsyncNilCallbacks

func TestAsyncNilCallbacks(t *testing.T) {
	done := make(chan struct{}, 1)

	err := StartAsync(exec.Command(find(t, "true")), &Callbacks{
		OnExit: func(state *os.ProcessState, err error) {
			done <- struct{}{}
		},
	})
	testutil.FatalOnErrT(t, "Error starting async: %v", err)

	err = StartAsync(exec.Command(find(t, "false")), &Callbacks{
		OnExit: func(state *os.ProcessState, err error) {
			done <- struct{}{}
		},
	})
	testutil.FatalOnErrT(t, "Error starting async: %v", err)

	err = StartAsync(exec.Command(find(t, "true")), &Callbacks{
		OnSuccess: func(state *os.ProcessState) {
			done <- struct{}{}
		},
	})
	testutil.FatalOnErrT(t, "Error starting async: %v", err)

	timeout := time.After(5 * time.Second)
	for i := 0; i < 3; i++ {
		select {
		case <-done:
		case <-timeout:
			t.Fatal("Process did not finish before timeout")
		}
	}
}
开发者ID:jwatt,项目名称:kythe,代码行数:33,代码来源:process_test.go

示例3: TestNodes

func TestNodes(t *testing.T) {
	st := tbl.Construct(t)

	for _, node := range tbl.Nodes {
		reply, err := st.Nodes(ctx, &xpb.NodesRequest{
			Ticket: []string{node.Ticket},
		})
		testutil.FatalOnErrT(t, "NodesRequest error: %v", err)

		if len(reply.Node) != 1 {
			t.Fatalf("Expected 1 node for %q; found %d: {%v}", node.Ticket, len(reply.Node), reply)
		} else if expected := nodeInfo(node); !reflect.DeepEqual(reply.Node[0], expected) {
			t.Fatalf("Expected {%v}; received {%v}", expected, reply.Node[0])
		}
	}

	var tickets []string
	var expected []*xpb.NodeInfo
	for _, n := range tbl.Nodes {
		tickets = append(tickets, n.Ticket)
		expected = append(expected, nodeInfo(n))
	}
	reply, err := st.Nodes(ctx, &xpb.NodesRequest{Ticket: tickets})
	testutil.FatalOnErrT(t, "NodesRequest error: %v", err)

	sort.Sort(byNodeTicket(expected))
	sort.Sort(byNodeTicket(reply.Node))

	if !reflect.DeepEqual(expected, reply.Node) {
		t.Fatalf("Expected {%v}; received {%v}", expected, reply.Node)
	}
}
开发者ID:pedrokiefer,项目名称:kythe,代码行数:32,代码来源:xrefs_test.go

示例4: TestNodes

func TestNodes(t *testing.T) {
	st := tbl.Construct(t)

	for _, node := range tbl.Nodes {
		reply, err := st.Nodes(ctx, &xpb.NodesRequest{
			Ticket: []string{node.Ticket},
		})
		testutil.FatalOnErrT(t, "NodesRequest error: %v", err)

		if len(reply.Nodes) != 1 {
			t.Fatalf("Expected 1 node for %q; found %d: {%v}", node.Ticket, len(reply.Nodes), reply)
		} else if err := testutil.DeepEqual(nodeInfo(node), reply.Nodes[node.Ticket]); err != nil {
			t.Fatal(err)
		}
	}

	var tickets []string
	expected := make(map[string]*xpb.NodeInfo)
	for _, n := range tbl.Nodes {
		tickets = append(tickets, n.Ticket)
		expected[n.Ticket] = nodeInfo(n)
	}
	reply, err := st.Nodes(ctx, &xpb.NodesRequest{Ticket: tickets})
	testutil.FatalOnErrT(t, "NodesRequest error: %v", err)

	if err := testutil.DeepEqual(expected, reply.Nodes); err != nil {
		t.Fatal(err)
	}
}
开发者ID:bowlofstew,项目名称:kythe,代码行数:29,代码来源:xrefs_test.go

示例5: OrderTest

// OrderTest tests the ordering of the streamed entries while reading from the
// CreateFunc created graphstore.Service.
func OrderTest(t *testing.T, create CreateFunc, batchSize int) {
	gs, destroy, err := create()
	testutil.FatalOnErrT(t, "CreateFunc error: %v", err)
	defer func() {
		testutil.FatalOnErrT(t, "gs close error: %v", gs.Close(ctx))
		testutil.FatalOnErrT(t, "DestroyFunc error: %v", destroy())
	}()

	updates := make([]spb.WriteRequest_Update, batchSize)
	req := &spb.WriteRequest{
		Source: &spb.VName{},
		Update: make([]*spb.WriteRequest_Update, batchSize),
	}
	for i := 0; i < 1024; i++ {
		randVName(req.Source, keySize)

		for j := 0; j < batchSize; j++ {
			randUpdate(&updates[j], keySize)
			req.Update[j] = &updates[j]
		}

		testutil.FatalOnErrT(t, "write error: %v", gs.Write(ctx, req))
	}

	var lastEntry *spb.Entry
	testutil.FatalOnErrT(t, "entryLess error: %v",
		gs.Scan(ctx, new(spb.ScanRequest), func(entry *spb.Entry) error {
			if compare.Entries(lastEntry, entry) != compare.LT {
				return fmt.Errorf("expected {%v} < {%v}", lastEntry, entry)
			}
			return nil
		}))
}
开发者ID:jwatt,项目名称:kythe,代码行数:35,代码来源:graphstore.go

示例6: TestParse

func TestParse(t *testing.T) {
	tests := []struct {
		str string
		sz  Size
	}{
		{"0", 0},
		{"1024", 1024 * Byte},
		{"100", 100 * Byte},
		{"0tb", 0},
		{"1b", Byte},
		{"1kb", Kilobyte},
		{"1mb", Megabyte},
		{"1Gb", Gigabyte},
		{"1tb", Terabyte},
		{"1Pb", Petabyte},
		{"1KiB", Kibibyte},
		{"1mib", Mebibyte},
		{"1gib", Gibibyte},
		{"1tib", Tebibyte},
		{"1PiB", Pebibyte},
		{"4TB", 4 * Terabyte},
		{"43.5MB", Size(43.5 * float64(Megabyte))},
	}

	for _, test := range tests {
		found, err := Parse(test.str)
		testutil.FatalOnErrT(t, "Unexpected error: %v", err)
		if found != test.sz {
			t.Errorf("Parse(%q): expected: %s; found: %s", test.str, test.sz, found)
		}
	}
}
开发者ID:jwatt,项目名称:kythe,代码行数:32,代码来源:datasize_test.go

示例7: Construct

func (tbl *testTable) Construct(t *testing.T) xrefs.Service {
	p := make(testProtoTable)
	for _, n := range tbl.Nodes {
		testutil.FatalOnErrT(t, "Error writing node: %v", p.Put(ctx, NodeKey(mustFix(t, n.Ticket)), n))
	}
	for _, es := range tbl.EdgeSets {
		testutil.FatalOnErrT(t, "Error writing edge set: %v", p.Put(ctx, EdgeSetKey(mustFix(t, es.EdgeSet.SourceTicket)), es))
	}
	for _, ep := range tbl.EdgePages {
		testutil.FatalOnErrT(t, "Error writing edge page: %v", p.Put(ctx, []byte(edgePagesTablePrefix+ep.PageKey), ep))
	}
	for _, d := range tbl.Decorations {
		testutil.FatalOnErrT(t, "Error writing file decorations: %v", p.Put(ctx, DecorationsKey(mustFix(t, d.FileTicket)), d))
	}
	return NewCombinedTable(table.ProtoBatchParallel{p})
}
开发者ID:pedrokiefer,项目名称:kythe,代码行数:16,代码来源:xrefs_test.go

示例8: TestDriverErrorHandler

func TestDriverErrorHandler(t *testing.T) {
	m := &mock{
		t:            t,
		Outputs:      outs("a", "b", "c"),
		Compilations: comps("target1", "target2"),
		AnalyzeError: errFromAnalysis,
	}
	var analysisErr error
	d := &Driver{
		Analyzer:     m,
		Compilations: m,
		Output:       m.out(),
		AnalysisError: func(_ context.Context, cu *apb.CompilationUnit, err error) error {
			analysisErr = err
			return nil // don't return err
		},
	}
	testutil.FatalOnErrT(t, "Driver error: %v", d.Run(context.Background()))
	if len(m.Requests) != len(m.Compilations) {
		t.Errorf("Expected %d AnalysisRequests; found %v", len(m.Compilations), m.Requests)
	}
	if analysisErr != errFromAnalysis {
		t.Errorf("Expected AnalysisError: %v; found: %v", errFromAnalysis, analysisErr)
	}
}
开发者ID:jwatt,项目名称:kythe,代码行数:25,代码来源:driver_test.go

示例9: TestDriver

func TestDriver(t *testing.T) {
	m := &mock{
		t:            t,
		Outputs:      outs("a", "b", "c"),
		Compilations: comps("target1", "target2"),
	}
	var setupIdx, teardownIdx int
	d := &Driver{
		Analyzer:     m,
		Compilations: m,
		Output:       m.out(),
		Setup: func(_ context.Context, cu *apb.CompilationUnit) error {
			setupIdx++
			return nil
		},
		Teardown: func(_ context.Context, cu *apb.CompilationUnit) error {
			if setupIdx != teardownIdx+1 {
				t.Error("Teardown was not called directly after Setup/Analyze")
			}
			teardownIdx++
			return nil
		},
	}
	testutil.FatalOnErrT(t, "Driver error: %v", d.Run(context.Background()))
	if len(m.Requests) != len(m.Compilations) {
		t.Errorf("Expected %d AnalysisRequests; found %v", len(m.Compilations), m.Requests)
	}
	if setupIdx != len(m.Compilations) {
		t.Errorf("Expected %d calls to Setup; found %d", len(m.Compilations), setupIdx)
	}
	if teardownIdx != len(m.Compilations) {
		t.Errorf("Expected %d calls to Teardown; found %d", len(m.Compilations), teardownIdx)
	}
}
开发者ID:jwatt,项目名称:kythe,代码行数:34,代码来源:driver_test.go

示例10: TestDecorationsRefs

func TestDecorationsRefs(t *testing.T) {
	d := tbl.Decorations[1]

	st := tbl.Construct(t)
	reply, err := st.Decorations(ctx, &xpb.DecorationsRequest{
		Location:   &xpb.Location{Ticket: d.FileTicket},
		References: true,
		Filter:     []string{"**"},
	})
	testutil.FatalOnErrT(t, "DecorationsRequest error: %v", err)

	if len(reply.SourceText) != 0 {
		t.Errorf("Unexpected source text: %q", string(d.SourceText))
	}
	if reply.Encoding != "" {
		t.Errorf("Unexpected encoding: %q", d.Encoding)
	}

	expected := refs(xrefs.NewNormalizer(d.SourceText), d.Decoration)
	if !reflect.DeepEqual(expected, reply.Reference) {
		t.Fatalf("Expected references %v; found %v", expected, reply.Reference)
	}

	expectedNodes := nodeInfos(tbl.Nodes[7:13])

	sort.Sort(byNodeTicket(expectedNodes))
	sort.Sort(byNodeTicket(reply.Node))

	if err := testutil.DeepEqual(expectedNodes, reply.Node); err != nil {
		t.Fatal(err)
	}
}
开发者ID:pedrokiefer,项目名称:kythe,代码行数:32,代码来源:xrefs_test.go

示例11: TestDecorationsDirtyBuffer

func TestDecorationsDirtyBuffer(t *testing.T) {
	d := tbl.Decorations[1]

	st := tbl.Construct(t)
	dirty := []byte(`(defn map [f coll]
  (if (seq coll)
    []
    (cons (f (first coll)) (map f (rest coll)))))
`)
	reply, err := st.Decorations(ctx, &xpb.DecorationsRequest{
		Location:    &xpb.Location{Ticket: d.FileTicket},
		DirtyBuffer: dirty,
		References:  true,
		Filter:      []string{"**"},
	})
	testutil.FatalOnErrT(t, "DecorationsRequest error: %v", err)

	if len(reply.SourceText) != 0 {
		t.Errorf("Unexpected source text: %q", string(d.SourceText))
	}
	if reply.Encoding != "" {
		t.Errorf("Unexpected encoding: %q", d.Encoding)
	}

	p := xrefs.NewPatcher(d.SourceText, dirty)
	norm := xrefs.NewNormalizer(dirty)
	var expected []*xpb.DecorationsReply_Reference
	for _, d := range d.Decoration {
		if _, _, exists := p.Patch(d.Anchor.StartOffset, d.Anchor.EndOffset); exists {
			expected = append(expected, decorationToReference(norm, d))
		}
	}
	if !reflect.DeepEqual(expected, reply.Reference) {
		t.Fatalf("Expected references %v; found %v", expected, reply.Reference)
	}

	// These are a subset of the anchor nodes in tbl.Decorations[1].  tbl.Nodes[8]
	// and tbl.Nodes[10] are missing because [8] was an anchor in the edited
	// region and [10] was its target.
	expectedNodes := nodeInfos([]*srvpb.Node{
		tbl.Nodes[7], tbl.Nodes[9], tbl.Nodes[11], tbl.Nodes[12],
	})

	// Ensure patching affects the anchor node facts
	mapFacts(expectedNodes[2], map[string]string{
		"/kythe/loc/start": "48",
		"/kythe/loc/end":   "52",
	})

	sort.Sort(byNodeTicket(expectedNodes))
	sort.Sort(byNodeTicket(reply.Node))

	if !reflect.DeepEqual(expectedNodes, reply.Node) {
		t.Fatalf("Expected nodes %v; found %v", expected, reply.Node)
	}
}
开发者ID:pedrokiefer,项目名称:kythe,代码行数:56,代码来源:xrefs_test.go

示例12: TestEdgesMissing

func TestEdgesMissing(t *testing.T) {
	st := tbl.Construct(t)
	reply, err := st.Edges(ctx, &xpb.EdgesRequest{
		Ticket: []string{"kythe:#someMissingTicket"},
	})
	testutil.FatalOnErrT(t, "EdgesRequest error: %v", err)

	if len(reply.EdgeSet) > 0 || len(reply.Node) > 0 || reply.NextPageToken != "" {
		t.Fatalf("Received unexpected reply for missing edges: {%v}", reply)
	}
}
开发者ID:pedrokiefer,项目名称:kythe,代码行数:11,代码来源:xrefs_test.go

示例13: TestNodesMissing

func TestNodesMissing(t *testing.T) {
	st := tbl.Construct(t)
	reply, err := st.Nodes(ctx, &xpb.NodesRequest{
		Ticket: []string{"kythe:#someMissingTicket"},
	})
	testutil.FatalOnErrT(t, "NodesRequest error: %v", err)

	if len(reply.Node) > 0 {
		t.Fatalf("Received unexpected reply for missing node: {%v}", reply)
	}
}
开发者ID:pedrokiefer,项目名称:kythe,代码行数:11,代码来源:xrefs_test.go

示例14: TestDriverEmpty

func TestDriverEmpty(t *testing.T) {
	m := &mock{t: t}
	d := &Driver{
		Analyzer:     m,
		Compilations: m,
		Output:       m.out(),
	}
	testutil.FatalOnErrT(t, "Driver error: %v", d.Run(context.Background()))
	if len(m.Requests) != 0 {
		t.Fatalf("Unexpected AnalysisRequests: %v", m.Requests)
	}
}
开发者ID:jwatt,项目名称:kythe,代码行数:12,代码来源:driver_test.go

示例15: Construct

func (tbl *testTable) Construct(t *testing.T) *Table {
	p := make(testProtoTable)
	var tickets stringset.Set
	for _, n := range tbl.Nodes {
		tickets.Add(n.Ticket)
	}
	for _, es := range tbl.EdgeSets {
		tickets.Discard(es.Source.Ticket)
		testutil.FatalOnErrT(t, "Error writing edge set: %v", p.Put(ctx, EdgeSetKey(mustFix(t, es.Source.Ticket)), es))
	}
	// Fill in EdgeSets for zero-degree nodes
	for ticket := range tickets {
		es := &srvpb.PagedEdgeSet{
			Source: getNode(ticket),
		}
		testutil.FatalOnErrT(t, "Error writing edge set: %v", p.Put(ctx, EdgeSetKey(mustFix(t, es.Source.Ticket)), es))
	}
	for _, ep := range tbl.EdgePages {
		testutil.FatalOnErrT(t, "Error writing edge page: %v", p.Put(ctx, EdgePageKey(ep.PageKey), ep))
	}
	for _, d := range tbl.Decorations {
		testutil.FatalOnErrT(t, "Error writing file decorations: %v", p.Put(ctx, DecorationsKey(mustFix(t, d.File.Ticket)), d))
	}
	for _, cr := range tbl.RefSets {
		testutil.FatalOnErrT(t, "Error writing cross-references: %v", p.Put(ctx, CrossReferencesKey(mustFix(t, cr.SourceTicket)), cr))
	}
	for _, crp := range tbl.RefPages {
		testutil.FatalOnErrT(t, "Error writing cross-references: %v", p.Put(ctx, CrossReferencesPageKey(crp.PageKey), crp))
	}
	return NewCombinedTable(table.ProtoBatchParallel{p})
}
开发者ID:benjyw,项目名称:kythe,代码行数:31,代码来源:xrefs_test.go


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