Update run-cts to allow skipping VSCode launch information.
The VSCode launch.json is emitted for every process that spins up. This
isn't useful for folks not using VSCode. This CL adds a
`--skip-vs-code-info` which suppresses the emission of the launch.json
data.
The execution command and current working directory are still emitted.
Change-Id: I02a3247a2f481913525ac546ffc6972fb3b0a253
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/178040
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/tools/src/cmd/run-cts/node/cmd.go b/tools/src/cmd/run-cts/node/cmd.go
index 6064260..cd7d35a 100644
--- a/tools/src/cmd/run-cts/node/cmd.go
+++ b/tools/src/cmd/run-cts/node/cmd.go
@@ -107,6 +107,7 @@
unrollConstEvalLoops bool
genCoverage bool
compatibilityMode bool
+ skipVSCodeInfo bool
dawn dawnFlags
}
@@ -154,6 +155,7 @@
flag.BoolVar(&c.flags.genCoverage, "coverage", false, "displays coverage data")
flag.StringVar(&c.flags.coverageFile, "export-coverage", "", "write coverage data to the given path")
flag.BoolVar(&c.flags.compatibilityMode, "compat", false, "run tests in compatibility mode")
+ flag.BoolVar(&c.flags.skipVSCodeInfo, "skip-vs-code-info", false, "skips emitting VS Code information")
return []string{"[query]"}, nil
}
diff --git a/tools/src/cmd/run-cts/node/cmdline.go b/tools/src/cmd/run-cts/node/cmdline.go
index e4cd029..990a909 100644
--- a/tools/src/cmd/run-cts/node/cmdline.go
+++ b/tools/src/cmd/run-cts/node/cmdline.go
@@ -122,7 +122,7 @@
cmd.Stderr = &buf
if c.flags.Verbose {
- PrintCommand(cmd)
+ PrintCommand(cmd, c.flags.skipVSCodeInfo)
}
start := time.Now()
diff --git a/tools/src/cmd/run-cts/node/print_command.go b/tools/src/cmd/run-cts/node/print_command.go
index 30adf16..5cf6af5 100644
--- a/tools/src/cmd/run-cts/node/print_command.go
+++ b/tools/src/cmd/run-cts/node/print_command.go
@@ -35,7 +35,7 @@
"strings"
)
-func PrintCommand(cmd *exec.Cmd) {
+func PrintCommand(cmd *exec.Cmd, skipVSCodeInfo bool) {
maybeQuote := func(s string) string {
if strings.ContainsAny(s, ` ,()"`) {
s = strings.ReplaceAll(s, `"`, `\"`)
@@ -56,26 +56,28 @@
fmt.Fprintln(output)
fmt.Fprintf(output, " Dir: %v\n\n", cmd.Dir)
- fmt.Fprint(output, " For VS Code launch.json:\n")
- launchCmd := struct {
- Program string `json:"program"`
- Args []string `json:"args"`
- Cwd string `json:"cwd"`
- }{
- Program: cmd.Path,
- Args: cmd.Args[1:],
- Cwd: cmd.Dir,
- }
+ if !skipVSCodeInfo {
+ fmt.Fprint(output, " For VS Code launch.json:\n")
+ launchCmd := struct {
+ Program string `json:"program"`
+ Args []string `json:"args"`
+ Cwd string `json:"cwd"`
+ }{
+ Program: cmd.Path,
+ Args: cmd.Args[1:],
+ Cwd: cmd.Dir,
+ }
- b := &bytes.Buffer{}
- e := json.NewEncoder(b)
- e.SetIndent("", " ")
- e.Encode(launchCmd)
- s := b.String()
- // Remove object braces and add trailing comma
- s = strings.TrimPrefix(s, "{\n")
- s = strings.TrimSuffix(s, "\n}\n") + ",\n"
- fmt.Fprintln(output, s)
+ b := &bytes.Buffer{}
+ e := json.NewEncoder(b)
+ e.SetIndent("", " ")
+ e.Encode(launchCmd)
+ s := b.String()
+ // Remove object braces and add trailing comma
+ s = strings.TrimPrefix(s, "{\n")
+ s = strings.TrimSuffix(s, "\n}\n") + ",\n"
+ fmt.Fprintln(output, s)
+ }
fmt.Print(output.String())
}
diff --git a/tools/src/cmd/run-cts/node/server.go b/tools/src/cmd/run-cts/node/server.go
index 3e9f96a..efb457d 100644
--- a/tools/src/cmd/run-cts/node/server.go
+++ b/tools/src/cmd/run-cts/node/server.go
@@ -145,7 +145,7 @@
cmd.Stderr = &pl
if c.flags.Verbose {
- PrintCommand(cmd)
+ PrintCommand(cmd, c.flags.skipVSCodeInfo)
}
err := cmd.Start()
if err != nil {