Skip to content

Commit 45ffdf6

Browse files
committed
Use %q to format-quote strings
1 parent 6616d81 commit 45ffdf6

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

testrunner/ast.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func FindAllRootLevelTests(fileName string) []rootLevelTest {
5050
ppc := parser.ParseComments
5151
file, err := parser.ParseFile(fset, fileName, nil, ppc)
5252
if err != nil {
53-
log.Printf("error: not able to parse '%s': %s", fileName, err)
53+
log.Printf("error: not able to parse %q: %s", fileName, err)
5454
return nil
5555
}
5656
for _, d := range file.Decls {
@@ -113,7 +113,7 @@ func getSubCode(test string, sub string, code string, file string, pkgName strin
113113
fset, file, pkgLine+code, parser.ParseComments,
114114
)
115115
if err != nil {
116-
log.Printf("warning: '%s' not parsed from '%s': %s", test, file, err)
116+
log.Printf("warning: %q not parsed from %q: %s", test, file, err)
117117
return ""
118118
}
119119

testrunner/ast_debug.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@
189189
" // `go test` returns 1 when tests fail \n",
190190
" // The test runner should continue and return 0 in this case \n",
191191
" log.Printf( \n",
192-
" \"warning: ignoring exit code 1 from '%s'\", testCmd.String(), \n",
192+
" \"warning: ignoring exit code 1 from %q\", testCmd.String(), \n",
193193
" ) \n",
194194
" } else { \n",
195-
" log.Fatalf(\"'%s' failed with exit code %d: %s\", \n",
195+
" log.Fatalf(\"%q failed with exit code %d: %s\", \n",
196196
" testCmd.String(), exitError.ExitCode(), err) \n",
197197
" } \n",
198198
" } \n",

testrunner/execute.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ func runTests(input_dir string, additionalTestFlags []string) (bytes.Buffer, boo
511511

512512
exitError, ok := err.(*exec.ExitError)
513513
if !ok {
514-
log.Fatalf("error: '%s' failed with non exit error %s",
514+
log.Fatalf("error: %q failed with non exit error %s",
515515
testCmd.String(), err,
516516
)
517517
}
@@ -522,7 +522,7 @@ func runTests(input_dir string, additionalTestFlags []string) (bytes.Buffer, boo
522522
// Combine stderr and stdout in the same order in which they
523523
// show up in the console.
524524
stderr.WriteString(stdout.String())
525-
stderr.WriteString(fmt.Sprintf("'%s' returned exit code %d: %s",
525+
stderr.WriteString(fmt.Sprintf("%q returned exit code %d: %s",
526526
testCmd.String(), exc, err,
527527
))
528528
return stderr, false
@@ -533,7 +533,7 @@ func runTests(input_dir string, additionalTestFlags []string) (bytes.Buffer, boo
533533
// `go test` returns 1 when tests fail, this is fine
534534
return stdout, true
535535
default:
536-
log.Fatalf("error: '%s' failed with exit error %d: %s",
536+
log.Fatalf("error: %q failed with exit error %d: %s",
537537
testCmd.String(), exc, err,
538538
)
539539
}

testrunner/extract.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func splitTestName(testName string) (string, string) {
2121
func FindTestFile(codePath string) string {
2222
files, err := os.ReadDir(codePath)
2323
if err != nil {
24-
log.Printf("warning: input_dir '%s' cannot be read: %s", codePath, err)
24+
log.Printf("warning: input_dir %q cannot be read: %s", codePath, err)
2525
return ""
2626
}
2727

@@ -30,7 +30,7 @@ func FindTestFile(codePath string) string {
3030
testpath := filepath.Join(codePath, f.Name())
3131
fh, err := os.ReadFile(testpath)
3232
if err != nil {
33-
log.Printf("warning: test file '%s' read failed: %s", testpath, err)
33+
log.Printf("warning: test file %q read failed: %s", testpath, err)
3434
}
3535

3636
// We need to check we found the file that actually contains the tests and not only the
@@ -41,7 +41,7 @@ func FindTestFile(codePath string) string {
4141
}
4242
}
4343
}
44-
log.Printf("error: test file not found in input_dir '%s'", codePath)
44+
log.Printf("error: test file not found in input_dir %q", codePath)
4545
return ""
4646
}
4747

0 commit comments

Comments
 (0)