Swap to using glob to enumerate all golden files, rather than hardcoding them

This commit is contained in:
David Dworken 2024-02-10 10:07:37 -08:00
parent f4694bdd28
commit ed22ae6e4f
No known key found for this signature in database

View File

@ -7,6 +7,7 @@ import (
"log"
"os"
"path"
"path/filepath"
"runtime"
"slices"
"strings"
@ -43,15 +44,15 @@ func checkGoldensUsed() {
}
// Read the goldens that were used
usedGoldens := make([]string, 0)
filenames := []string{
"goldens-used-macos-14-BASIC/goldens-used.txt", "goldens-used-macos-14-TUI/goldens-used.txt",
"goldens-used-macos-latest-BASIC/goldens-used.txt", "goldens-used-macos-latest-TUI/goldens-used.txt",
"goldens-used-ubuntu-latest-BASIC/goldens-used.txt", "goldens-used-ubuntu-latest-TUI/goldens-used.txt",
filenames, err := filepath.Glob("*/goldens-used.txt")
if err != nil {
log.Fatalf("failed to list golden files: %v", err)
}
fmt.Printf("Found used goldens in %#v\n", filenames)
for _, filename := range filenames {
usedGoldensFile, err := os.Open(filename)
if err != nil {
log.Fatalf("failed to open /tmp/goldens-used.txt: %v", err)
log.Fatalf("failed to open %s: %v", filename, err)
}
defer usedGoldensFile.Close()
scanner := bufio.NewScanner(usedGoldensFile)