[perf] Fix ingest parser bug.
Change-Id: I4dc3fed9c7da0de5e504d592fbb50ac72e166746
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/279419
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
diff --git a/perf/go/ingest/parser/parser.go b/perf/go/ingest/parser/parser.go
index 44a6795..58f4584 100644
--- a/perf/go/ingest/parser/parser.go
+++ b/perf/go/ingest/parser/parser.go
@@ -122,6 +122,9 @@
// then the file should be processed, in which case the returned branch name is
// "".
func (p *Parser) checkBranchName(params map[string]string) (string, bool) {
+ if len(p.branchNames) == 0 {
+ return "", true
+ }
branch, ok := params["branch"]
if ok {
return branch, p.branchNames[branch]
diff --git a/perf/go/ingest/parser/parser_test.go b/perf/go/ingest/parser/parser_test.go
index a45bb70..43fe63d 100644
--- a/perf/go/ingest/parser/parser_test.go
+++ b/perf/go/ingest/parser/parser_test.go
@@ -108,6 +108,7 @@
filename string
}{
"parse_Success": {parse_Success, "success.json"},
+ "parse_NoBranchSpecified_Success": {parse_NoBranchSpecified_Success, "success.json"},
"parse_MalformedJSONError": {parse_MalformedJSONError, "invalid.json"},
"parse_SkipIfNotListedInBranches": {parse_SkipIfNotListedInBranches, "unknown_branch.json"},
"parse_SkipIfListedInBranchesButHasNoData": {parse_SkipIfListedInBranchesButHasNoData, "no_results.json"},
@@ -127,6 +128,19 @@
assert.Equal(t, int64(0), p.parseFailCounter.Get())
}
+func parse_NoBranchSpecified_Success(t *testing.T, p *Parser, f file.File) {
+ p.branchNames = nil
+ params, values, gitHash, err := p.Parse(f)
+ require.NoError(t, err)
+ assert.Equal(t, "fe4a4029a080bc955e9588d05a6cd9eb490845d4", gitHash)
+ assert.Len(t, values, 4)
+ assert.Len(t, params, 4)
+ assert.Contains(t, values, float32(858))
+ assert.Contains(t, params, expectedGoodParams)
+ assert.Equal(t, int64(1), p.parseCounter.Get())
+ assert.Equal(t, int64(0), p.parseFailCounter.Get())
+}
+
func parse_MalformedJSONError(t *testing.T, p *Parser, f file.File) {
_, _, _, err := p.Parse(f)
require.Error(t, err)