mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
Add a slow_tests.txt file
This file should hold all Slow expectations. Overlaps here are allowed. Bug: dawn:1832 Change-Id: I69b4e53614d9eeed68315b127f2d37ed76b00026 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133565 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
@@ -26,6 +26,10 @@ const (
|
||||
// expectations.txt file.
|
||||
RelativeExpectationsPath = "webgpu-cts/expectations.txt"
|
||||
|
||||
// RelativeSlowExpectationsPath is the dawn-root relative path to the
|
||||
// slow_tests.txt file.
|
||||
RelativeSlowExpectationsPath = "webgpu-cts/slow_tests.txt"
|
||||
|
||||
// RelativeTestListPath is the dawn-root relative path to the
|
||||
// test_list.txt file.
|
||||
RelativeTestListPath = "third_party/gn/webgpu-cts/test_list.txt"
|
||||
@@ -41,6 +45,16 @@ func DefaultExpectationsPath() string {
|
||||
return path
|
||||
}
|
||||
|
||||
// DefaultSlowExpectationsPath returns the default path to the slow_tests.txt
|
||||
// file. Returns an empty string if the file cannot be found.
|
||||
func DefaultSlowExpectationsPath() string {
|
||||
path := filepath.Join(fileutils.DawnRoot(), RelativeSlowExpectationsPath)
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return ""
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// DefaultTestListPath returns the default path to the test_list.txt
|
||||
// file. Returns an empty string if the file cannot be found.
|
||||
func DefaultTestListPath() string {
|
||||
|
||||
@@ -31,6 +31,7 @@ func init() {
|
||||
type cmd struct {
|
||||
flags struct {
|
||||
expectations string // expectations file path
|
||||
slow string // slow test expectations file path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,16 +45,19 @@ func (cmd) Desc() string {
|
||||
|
||||
func (c *cmd) RegisterFlags(ctx context.Context, cfg common.Config) ([]string, error) {
|
||||
defaultExpectations := common.DefaultExpectationsPath()
|
||||
flag.StringVar(&c.flags.expectations, "expectations", defaultExpectations, "path to CTS expectations file to update")
|
||||
slowExpectations := common.DefaultSlowExpectationsPath()
|
||||
flag.StringVar(&c.flags.expectations, "expectations", defaultExpectations, "path to CTS expectations file to validate")
|
||||
flag.StringVar(&c.flags.slow, "slow", slowExpectations, "path to CTS slow expectations file to validate")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *cmd) Run(ctx context.Context, cfg common.Config) error {
|
||||
ex, err := expectations.Load(c.flags.expectations)
|
||||
// Load expectations.txt
|
||||
content, err := expectations.Load(c.flags.expectations)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
diags := ex.Validate()
|
||||
diags := content.Validate()
|
||||
|
||||
// Print any diagnostics
|
||||
diags.Print(os.Stdout, c.flags.expectations)
|
||||
@@ -61,6 +65,19 @@ func (c *cmd) Run(ctx context.Context, cfg common.Config) error {
|
||||
return fmt.Errorf("%v errors found", numErrs)
|
||||
}
|
||||
|
||||
// Load slow_tests.txt
|
||||
content, err = expectations.Load(c.flags.slow)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
diags = content.ValidateSlowTests()
|
||||
// Print any diagnostics
|
||||
diags.Print(os.Stdout, c.flags.expectations)
|
||||
if numErrs := diags.NumErrors(); numErrs > 0 {
|
||||
return fmt.Errorf("%v errors found", numErrs)
|
||||
}
|
||||
|
||||
fmt.Println("no issues found")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
"dawn.googlesource.com/dawn/tools/src/container"
|
||||
"dawn.googlesource.com/dawn/tools/src/cts/query"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func (c Content) tagsCollide(a, b container.Set[string]) bool {
|
||||
@@ -75,3 +76,20 @@ func (c Content) Validate() Diagnostics {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ValidateSlowTests checks that the expectations are only [ Slow ]
|
||||
func (c Content) ValidateSlowTests() Diagnostics {
|
||||
var out Diagnostics
|
||||
for _, chunk := range c.Chunks {
|
||||
for _, ex := range chunk.Expectations {
|
||||
if !cmp.Equal(ex.Status, []string{"Slow"}) {
|
||||
out = append(out, Diagnostic{
|
||||
Severity: Error,
|
||||
Line: ex.Line,
|
||||
Message: fmt.Sprintf("slow test expectation for %v must be %v but was %v", ex.Query, []string{"Slow"}, ex.Status),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user