Commit 79b4b0ed by Ben Clayton

Regres: Re-populate treeFile.allSpans on parse.

This caused `TestTreeEncodeDecode` to fail, and would make the reparsing of a coverage file incorrect. Bug: b/152192800 Change-Id: Ic9f4c49c58350509f74755fec20f22b6c1213877 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43569Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 1d1d0e1a
...@@ -312,9 +312,35 @@ func (p *parser) parse() (*Tree, string, error) { ...@@ -312,9 +312,35 @@ func (p *parser) parse() (*Tree, string, error) {
if p.err != nil { if p.err != nil {
return nil, "", p.err return nil, "", p.err
} }
p.populateAllSpans(&p.tree)
return &p.tree, p.revision, nil return &p.tree, p.revision, nil
} }
// populateAllSpans() adds all the coverage spans to each treeFile.allSpans.
func (p *parser) populateAllSpans(tree *Tree) {
spansByID := map[SpanID]Span{}
for span, id := range tree.spans {
spansByID[id] = span
}
for _, tf := range tree.files {
tf.tcm.traverse(func(tc *TestCoverage) {
for spanID := range tc.Spans {
span := spansByID[spanID]
tf.allSpans.Add(span)
}
if groupID := tc.Group; groupID != nil {
group := tf.spangroups[*groupID]
for spanID := range group.Spans {
span := spansByID[spanID]
tf.allSpans.Add(span)
}
}
})
}
}
func (p *parser) parseStrings() { func (p *parser) parseStrings() {
p.array(func(idx int) { p.array(func(idx int) {
id := StringID(idx) id := StringID(idx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment