run-cts : default "cts" arg to third_party/webgpu-cts if found
Change-Id: Ia052e92d17be5ce2068a14d74b5cdc2c43cf625f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85160 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
9be06c8d23
commit
e5474a4efc
|
@ -134,7 +134,7 @@ func run() error {
|
||||||
var numRunners int
|
var numRunners int
|
||||||
var flags dawnNodeFlags
|
var flags dawnNodeFlags
|
||||||
flag.StringVar(&dawnNode, "dawn-node", "", "path to dawn.node module")
|
flag.StringVar(&dawnNode, "dawn-node", "", "path to dawn.node module")
|
||||||
flag.StringVar(&cts, "cts", "", "root directory of WebGPU CTS")
|
flag.StringVar(&cts, "cts", defaultCtsPath(), "root directory of WebGPU CTS")
|
||||||
flag.StringVar(&node, "node", defaultNodePath(), "path to node executable")
|
flag.StringVar(&node, "node", defaultNodePath(), "path to node executable")
|
||||||
flag.StringVar(&npx, "npx", "", "path to npx executable")
|
flag.StringVar(&npx, "npx", "", "path to npx executable")
|
||||||
flag.StringVar(&resultsPath, "output", "", "path to write test results file")
|
flag.StringVar(&resultsPath, "output", "", "path to write test results file")
|
||||||
|
@ -1075,7 +1075,8 @@ func saveExpectations(path string, ex testcaseStatuses) error {
|
||||||
// command line flag.
|
// command line flag.
|
||||||
func defaultNodePath() string {
|
func defaultNodePath() string {
|
||||||
if dir := thisDir(); dir != "" {
|
if dir := thisDir(); dir != "" {
|
||||||
node := filepath.Join(dir, "../../../../../../../third_party/node")
|
if dawnRoot := getDawnRoot(); dawnRoot != "" {
|
||||||
|
node := filepath.Join(dawnRoot, "third_party/node")
|
||||||
if info, err := os.Stat(node); err == nil && info.IsDir() {
|
if info, err := os.Stat(node); err == nil && info.IsDir() {
|
||||||
path := ""
|
path := ""
|
||||||
switch fmt.Sprintf("%v/%v", runtime.GOOS, runtime.GOARCH) { // See `go tool dist list`
|
switch fmt.Sprintf("%v/%v", runtime.GOOS, runtime.GOARCH) { // See `go tool dist list`
|
||||||
|
@ -1093,6 +1094,7 @@ func defaultNodePath() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if path, err := exec.LookPath("node"); err == nil {
|
if path, err := exec.LookPath("node"); err == nil {
|
||||||
return path
|
return path
|
||||||
|
@ -1101,6 +1103,45 @@ func defaultNodePath() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defaultCtsPath looks for the webgpu-cts directory in dawn's third_party
|
||||||
|
// directory. This is used as the default for the --cts command line flag.
|
||||||
|
func defaultCtsPath() string {
|
||||||
|
if dir := thisDir(); dir != "" {
|
||||||
|
if dawnRoot := getDawnRoot(); dawnRoot != "" {
|
||||||
|
cts := filepath.Join(dawnRoot, "third_party/webgpu-cts")
|
||||||
|
if info, err := os.Stat(cts); err == nil && info.IsDir() {
|
||||||
|
return cts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// getDawnRoot returns the path to the dawn project's root directory or empty
|
||||||
|
// string if not found.
|
||||||
|
func getDawnRoot() string {
|
||||||
|
return getPathOfFileInParentDirs(thisDir(), "DEPS")
|
||||||
|
}
|
||||||
|
|
||||||
|
// getPathOfFileInParentDirs looks for file with `name` in paths starting from
|
||||||
|
// `path`, and up into parent directories, returning the clean path in which the
|
||||||
|
// file is found, or empty string if not found.
|
||||||
|
func getPathOfFileInParentDirs(path string, name string) string {
|
||||||
|
sep := string(filepath.Separator)
|
||||||
|
path, _ = filepath.Abs(path)
|
||||||
|
numDirs := strings.Count(path, sep) + 1
|
||||||
|
for i := 0; i < numDirs; i++ {
|
||||||
|
test := filepath.Join(path, name)
|
||||||
|
if _, err := os.Stat(test); err == nil {
|
||||||
|
return filepath.Clean(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
path = path + sep + ".."
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// thisDir returns the path to the directory that holds the .go file of the
|
// thisDir returns the path to the directory that holds the .go file of the
|
||||||
// caller function
|
// caller function
|
||||||
func thisDir() string {
|
func thisDir() string {
|
||||||
|
|
Loading…
Reference in New Issue