mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +00:00
transform: add -print-allocs-cover and restore -print-allocs reason output
PR #5220 changed -print-allocs output to the go coverage tool format, which replaced the original human-readable explanation of why each object had to be heap allocated. That explanation is useful on its own, so this restores it as the default behavior of -print-allocs and moves the coverage format behind a -print-allocs-cover flag. Signed-off-by: Piotr Bocheński <piotr@bochen.ski>
This commit is contained in:
committed by
Ron Evans
parent
c33113ab5f
commit
4465360f3d
@@ -24,6 +24,24 @@ var defaultTestConfig = &compileopts.Config{
|
||||
Options: &compileopts.Options{Opt: "2"},
|
||||
}
|
||||
|
||||
// checkGolden compares got against the golden file at path, or rewrites that
|
||||
// file when the test is run with -update.
|
||||
func checkGolden(t *testing.T, path, got string) {
|
||||
if *update {
|
||||
if err := os.WriteFile(path, []byte(got), 0o666); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
want, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != string(want) {
|
||||
t.Errorf("%s does not match expected output:\n%s", path, got)
|
||||
}
|
||||
}
|
||||
|
||||
// testTransform runs a transformation pass on an input file (pathPrefix+".ll")
|
||||
// and checks whether it matches the expected output (pathPrefix+".out.ll"). The
|
||||
// output is compared with a fuzzy match that ignores some irrelevant lines such
|
||||
|
||||
Reference in New Issue
Block a user