MCPcopy Create free account
hub / github.com/GoTestTools/gotestfmt / parse

Function parse

parser/parse.go:36–183  ·  view source on GitHub ↗
(
	evts <-chan tokenizer.Event,
	prefixChannel chan string,
	downloadsChannel chan *Downloads,
	downloadsFailureReason chan string,
	packagesChannel chan *Package,
)

Source from the content-addressed store, hash-verified

34}
35
36func parse(
37 evts <-chan tokenizer.Event,
38 prefixChannel chan string,
39 downloadsChannel chan *Downloads,
40 downloadsFailureReason chan string,
41 packagesChannel chan *Package,
42) {
43 outputStarted := false
44 downloadTracker := &downloadsTracker{
45 prefixChannel: prefixChannel,
46 downloadResultsList: nil,
47 downloadsByPackage: map[string]*Download{},
48 downloadsFinished: false,
49 downloadsFailureReason: downloadsFailureReason,
50 target: downloadsChannel,
51 }
52 pkgTracker := &packageTracker{
53 packagesByName: map[string]*Package{},
54 target: packagesChannel,
55 }
56
57 defer func() {
58 downloadTracker.Write()
59 pkgTracker.Write()
60 close(packagesChannel)
61 }()
62
63 var prevErroredDownload string
64 var prevErroredPkg string
65 for {
66 evt, ok := <-evts
67 if !ok {
68 return
69 }
70
71 if evt.Action != tokenizer.ActionStdout {
72 outputStarted = true
73 }
74 if evt.Action != tokenizer.ActionDownload && evt.Action != tokenizer.ActionDownloadFailed && evt.Package != "" {
75 pkgTracker.SetTestStartTime(evt.Package, evt.Test, evt.Received)
76 if evt.Elapsed != 0 {
77 pkgTracker.SetTestElapsed(evt.Package, evt.Test, evt.Elapsed)
78 }
79 if evt.Coverage != nil {
80 pkgTracker.SetCoverage(evt.Package, evt.Test, *evt.Coverage)
81 }
82 if evt.Cached {
83 pkgTracker.SetCached(evt.Package, evt.Test)
84 }
85 }
86
87 switch evt.Action {
88 case tokenizer.ActionFailFinal:
89 pkgTracker.SetResult(evt.Package, evt.Test, ResultFail)
90 if len(evt.Output) > 0 {
91 pkgTracker.AddReason(evt.Package, string(evt.Output))
92 }
93 case tokenizer.ActionSkipFinal:

Callers 1

ParseFunction · 0.85

Calls 13

WriteMethod · 0.95
WriteMethod · 0.95
SetTestStartTimeMethod · 0.95
SetTestElapsedMethod · 0.95
SetCoverageMethod · 0.95
SetCachedMethod · 0.95
SetResultMethod · 0.95
AddReasonMethod · 0.95
AddMethod · 0.95
SetDownloadFailedMethod · 0.95
AddReasonMethod · 0.95
AddOutputMethod · 0.95

Tested by

no test coverage detected