From 4489109c86c64330dc7005cc9d279370cce7a71a Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 14 Apr 2023 18:26:36 +0000 Subject: [PATCH] tools/cts/roll: Preserve RetryOnFailure expectations It's intended for the Unexpected Pass Finder to clean these up. This should help prevent known flakes from causing retries. Bug: chromium:1426512 Change-Id: I58c7baf2585dc4ca2e061e4a53c7b7d0f41e0af9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127420 Auto-Submit: Ben Clayton Kokoro: Kokoro Reviewed-by: Austin Eng Commit-Queue: Austin Eng --- tools/src/cts/expectations/update.go | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/src/cts/expectations/update.go b/tools/src/cts/expectations/update.go index 155e142090..222914273c 100644 --- a/tools/src/cts/expectations/update.go +++ b/tools/src/cts/expectations/update.go @@ -73,6 +73,10 @@ func (c *Content) Update(results result.List, testlist []query.Query) (Diagnosti tagSets: tagSets, } + if err := u.preserveRetryOnFailures(); err != nil { + return nil, err + } + // Update those expectations! if err := u.build(); err != nil { return nil, fmt.Errorf("while updating expectations: %w", err) @@ -263,6 +267,35 @@ func (qt *queryTree) markAsConsumed(q query.Query, t result.Tags, line int) { } } +// preserveRetryOnFailures changes any results matching expectations with a +// RetryOnFailure expectation to RetryOnFailure. +func (u *updater) preserveRetryOnFailures() error { + // For each expectation... + for _, c := range u.in.Chunks { + for _, ex := range c.Expectations { + // Does the expectation contain a RetryOnFailure status? + if !container.NewSet(ex.Status...).Contains(string(result.RetryOnFailure)) { + continue // Nope. + } + + q := query.Parse(ex.Query) + + glob, err := u.qt.tree.Glob(q) + if err != nil { + return err + } + for _, indices := range glob { + for _, idx := range indices.Data { + if u.qt.results[idx].Tags.ContainsAll(ex.Tags) { + u.qt.results[idx].Status = result.RetryOnFailure + } + } + } + } + } + return nil +} + // build is the updater top-level function. // build first appends to u.out all chunks from 'u.in' with expectations updated // using the new results, and then appends any new expectations to u.out.