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>
diff --git a/tools/src/cmd/cts/roll/roll.go b/tools/src/cmd/cts/roll/roll.go
index 432a15b..71c0e27 100644
--- a/tools/src/cmd/cts/roll/roll.go
+++ b/tools/src/cmd/cts/roll/roll.go
@@ -46,10 +46,11 @@
 }
 
 const (
-	depsRelPath      = "DEPS"
-	tsSourcesRelPath = "third_party/gn/webgpu-cts/ts_sources.txt"
-	refMain          = "refs/heads/main"
-	noExpectations   = `# Clear all expectations to obtain full list of results`
+	depsRelPath          = "DEPS"
+	tsSourcesRelPath     = "third_party/gn/webgpu-cts/ts_sources.txt"
+	resourceFilesRelPath = "third_party/gn/webgpu-cts/resource_files.txt"
+	refMain              = "refs/heads/main"
+	noExpectations       = `# Clear all expectations to obtain full list of results`
 )
 
 type rollerFlags struct {
@@ -235,6 +236,12 @@
 		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
 	existingRolls, err := r.findExistingRolls()
 	if err != nil {
@@ -276,6 +283,7 @@
 		depsRelPath:                     updatedDEPS,
 		common.RelativeExpectationsPath: ex.String(),
 		tsSourcesRelPath:                tsSources,
+		resourceFilesRelPath:            resources,
 	})
 	if err != nil {
 		return fmt.Errorf("failed to update change '%v': %v", changeID, err)
@@ -592,3 +600,21 @@
 
 	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
+}