aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2025-10-26 22:51:14 -0400
committerRuss Cox <rsc@golang.org>2025-10-29 13:55:00 -0700
commit915c1839fe76aef4bea6191282be1e48ef1c64e2 (patch)
treeb563df58f5cc2438206d7adf45bdfa58fa389837 /src/cmd
parent32ee3f3f73dc09f1981d295963bd705b6b9941da (diff)
downloadgo-915c1839fe76aef4bea6191282be1e48ef1c64e2.tar.xz
test/codegen: simplify asmcheck pattern matching
Separate patterns in asmcheck by spaces instead of commas. Many patterns end in comma (like "MOV [$]123,") so separating patterns by comma is not great; they're already quoted, so spaces are fine. Also replace all tabs in the assembly lines with spaces before matching. Finally, replace \$ or \\$ with [$] as the matching idiom. The effect of all these is to make the patterns look like: // amd64:"BSFQ" "ORQ [$]256" instead of the old: // amd64:"BSFQ","ORQ\t\\$256" Update all tests as well. Change-Id: Ia39febe5d7f67ba115846422789e11b185d5c807 Reviewed-on: https://go-review.googlesource.com/c/go/+/716060 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/internal/testdir/testdir_test.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cmd/internal/testdir/testdir_test.go b/src/cmd/internal/testdir/testdir_test.go
index c5aa91ba47..30e66c428d 100644
--- a/src/cmd/internal/testdir/testdir_test.go
+++ b/src/cmd/internal/testdir/testdir_test.go
@@ -1488,7 +1488,7 @@ var (
// "\s*,\s*` matches " , "
// second reMatchCheck matches "`SUB`"
// ")*)" closes started groups; "*" means that there might be other elements in the comma-separated list
- rxAsmPlatform = regexp.MustCompile(`(\w+)(/[\w.]+)?(/\w*)?\s*:\s*(` + reMatchCheck + `(?:\s*,\s*` + reMatchCheck + `)*)`)
+ rxAsmPlatform = regexp.MustCompile(`(\w+)(/[\w.]+)?(/\w*)?\s*:\s*(` + reMatchCheck + `(?:\s+` + reMatchCheck + `)*)`)
// Regexp to extract a single opcoded check
rxAsmCheck = regexp.MustCompile(reMatchCheck)
@@ -1701,6 +1701,9 @@ func (t test) asmCheck(outStr string, fn string, env buildEnv, fullops map[strin
}
srcFileLine, asm := matches[1], matches[2]
+ // Replace tabs with single spaces to make matches easier to write.
+ asm = strings.ReplaceAll(asm, "\t", " ")
+
// Associate the original file/line information to the current
// function in the output; it will be useful to dump it in case
// of error.
@@ -1752,11 +1755,11 @@ func (t test) asmCheck(outStr string, fn string, env buildEnv, fullops map[strin
}
if o.negative {
- fmt.Fprintf(&errbuf, "%s:%d: %s: wrong opcode found: %q\n", t.goFileName(), o.line, env, o.opcode.String())
+ fmt.Fprintf(&errbuf, "%s:%d: %s: wrong opcode found: %#q\n", t.goFileName(), o.line, env, o.opcode.String())
} else if o.expected > 0 {
- fmt.Fprintf(&errbuf, "%s:%d: %s: wrong number of opcodes: %q\n", t.goFileName(), o.line, env, o.opcode.String())
+ fmt.Fprintf(&errbuf, "%s:%d: %s: wrong number of opcodes: %#q\n", t.goFileName(), o.line, env, o.opcode.String())
} else {
- fmt.Fprintf(&errbuf, "%s:%d: %s: opcode not found: %q\n", t.goFileName(), o.line, env, o.opcode.String())
+ fmt.Fprintf(&errbuf, "%s:%d: %s: opcode not found: %#q\n", t.goFileName(), o.line, env, o.opcode.String())
}
}
return errors.New(errbuf.String())