tools/test-all.sh: Reimplement in golang

Makes future development easier.

New features:
* A more compact and cleaner results view
* Concurrent testing, much quicker across multiple cores
* Supports comparing output against an expected file, including a text diff of differences. Also has a flag for updating the expected outputs
* Advanced file-globbing support, including scanning for files in subdirectories
* Skip lists are now no longer hidden away in the tool, but defined as a SKIP header in the *.expected.* file

Change-Id: I4fac80bb084a720ec9a307b4acf9f73792973a1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50903
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2021-05-14 19:48:43 +00:00
committed by Commit Bot service account
parent 72f6ba4efe
commit 57b2a06ba7
10 changed files with 509 additions and 153 deletions

View File

@@ -22,6 +22,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"dawn.googlesource.com/tint/tools/src/match"
)
@@ -92,7 +93,12 @@ func LoadConfig(path string) (Config, error) {
if err != nil {
return Config{}, err
}
d := json.NewDecoder(bytes.NewReader(cfgBody))
return ParseConfig(string(cfgBody))
}
// ParseConfig parses the config from a JSON string.
func ParseConfig(config string) (Config, error) {
d := json.NewDecoder(strings.NewReader(config))
cfg := Config{}
if err := d.Decode(&cfg); err != nil {
return Config{}, err
@@ -100,6 +106,17 @@ func LoadConfig(path string) (Config, error) {
return cfg, nil
}
// MustParseConfig parses the config from a JSON string, panicing if the config
// does not parse
func MustParseConfig(config string) Config {
d := json.NewDecoder(strings.NewReader(config))
cfg := Config{}
if err := d.Decode(&cfg); err != nil {
panic(fmt.Errorf("Failed to parse config: %w\nConfig:\n%v", err, config))
}
return cfg
}
// rule is a search path predicate.
// root is the project relative path.
// cond is the value to return if the rule doesn't either include or exclude.