tools: Automatically generate resource_files.txt

When running `tools/run cts roll`

Bug: dawn:1342
Change-Id: I6af9a34fd4236c804ece32e0777f58ec98504f7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91849
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2022-05-27 18:58:30 +00:00 committed by Dawn LUCI CQ
parent aff5e9e722
commit 2cefd07454
1 changed files with 30 additions and 4 deletions

View File

@ -46,10 +46,11 @@ func init() {
} }
const ( const (
depsRelPath = "DEPS" depsRelPath = "DEPS"
tsSourcesRelPath = "third_party/gn/webgpu-cts/ts_sources.txt" tsSourcesRelPath = "third_party/gn/webgpu-cts/ts_sources.txt"
refMain = "refs/heads/main" resourceFilesRelPath = "third_party/gn/webgpu-cts/resource_files.txt"
noExpectations = `# Clear all expectations to obtain full list of results` refMain = "refs/heads/main"
noExpectations = `# Clear all expectations to obtain full list of results`
) )
type rollerFlags struct { type rollerFlags struct {
@ -235,6 +236,12 @@ func (r *roller) roll(ctx context.Context) error {
return fmt.Errorf("failed to generate ts_sources.txt: %v", err) return fmt.Errorf("failed to generate ts_sources.txt: %v", err)
} }
// Regenerate the resource files list
resources, err := r.genResourceFilesList(ctx)
if err != nil {
return fmt.Errorf("failed to generate resource_files.txt: %v", err)
}
// Look for an existing gerrit change to update // Look for an existing gerrit change to update
existingRolls, err := r.findExistingRolls() existingRolls, err := r.findExistingRolls()
if err != nil { if err != nil {
@ -276,6 +283,7 @@ func (r *roller) roll(ctx context.Context) error {
depsRelPath: updatedDEPS, depsRelPath: updatedDEPS,
common.RelativeExpectationsPath: ex.String(), common.RelativeExpectationsPath: ex.String(),
tsSourcesRelPath: tsSources, tsSourcesRelPath: tsSources,
resourceFilesRelPath: resources,
}) })
if err != nil { if err != nil {
return fmt.Errorf("failed to update change '%v': %v", changeID, err) return fmt.Errorf("failed to update change '%v': %v", changeID, err)
@ -592,3 +600,21 @@ func (r *roller) genTSDepList(ctx context.Context) (string, error) {
return strings.Join(deps, "\n") + "\n", nil return strings.Join(deps, "\n") + "\n", nil
} }
// genResourceFilesList returns a list of resource files, for the CTS checkout at r.ctsDir
// This list can be used to populate the resource_files.txt file.
func (r *roller) genResourceFilesList(ctx context.Context) (string, error) {
dir := filepath.Join(r.ctsDir, "src", "resources")
files, err := filepath.Glob(filepath.Join(dir, "*"))
if err != nil {
return "", err
}
for i, file := range files {
file, err := filepath.Rel(dir, file)
if err != nil {
return "", err
}
files[i] = file
}
return strings.Join(files, "\n") + "\n", nil
}