test-runner: Pass a relative path to tint
Avoids absolute paths being emitted in diagnostics
Change-Id: Ic62af27e079ceac8d89735486edcaca75014b8c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53382
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/tools/src/cmd/test-runner/main.go b/tools/src/cmd/test-runner/main.go
index 8345e3e..63d6f59 100644
--- a/tools/src/cmd/test-runner/main.go
+++ b/tools/src/cmd/test-runner/main.go
@@ -99,6 +99,10 @@
if !fileutils.IsExe(exe) {
return fmt.Errorf("'%s' not found or is not executable", exe)
}
+ exe, err := filepath.Abs(exe)
+ if err != nil {
+ return err
+ }
// Split the --filter flag up by ',', trimming any whitespace at the start and end
globIncludes := strings.Split(filter, ",")
@@ -200,7 +204,7 @@
go func() {
defer wg.Done()
for job := range jobs {
- job.run(exe, dxcPath, xcrunPath, generateExpected, generateSkip)
+ job.run(dir, exe, dxcPath, xcrunPath, generateExpected, generateSkip)
}
}()
}
@@ -356,7 +360,7 @@
result *status
}
-func (j job) run(exe, dxcPath, xcrunPath string, generateExpected, generateSkip bool) {
+func (j job) run(wd, exe, dxcPath, xcrunPath string, generateExpected, generateSkip bool) {
// Is there an expected output?
expected := loadExpectedFile(j.file, j.format)
skipped := false
@@ -366,7 +370,15 @@
expected = strings.ReplaceAll(expected, "\r\n", "\n")
- args := []string{j.file, "--format", string(j.format)}
+ file, err := filepath.Rel(wd, j.file)
+ if err != nil {
+ file = j.file
+ }
+
+ args := []string{
+ file,
+ "--format", string(j.format),
+ }
// Can we validate?
switch j.format {
@@ -383,7 +395,7 @@
}
// Invoke the compiler...
- ok, out := invoke(exe, args...)
+ ok, out := invoke(wd, exe, args...)
out = strings.ReplaceAll(out, "\r\n", "\n")
matched := expected == "" || expected == out
@@ -507,8 +519,9 @@
}
// invoke runs the executable 'exe' with the provided arguments.
-func invoke(exe string, args ...string) (ok bool, output string) {
+func invoke(wd, exe string, args ...string) (ok bool, output string) {
cmd := exec.Command(exe, args...)
+ cmd.Dir = wd
out, err := cmd.CombinedOutput()
str := string(out)
if err != nil {