Skip to content

Commit c8f6135

Browse files
committed
test: add regression test from #41474
This issue was fixed with multiple individual compiler optimizations, each of which had their own respective test cases. This CL just adds the capstone test case to demonstrate that the issue has been fixed and doesn't regress again. Updates #41474. Change-Id: Iae752d4b0e7b83ee356b946843340a4fbc254058 Reviewed-on: https://go-review.googlesource.com/c/go/+/263097 Trust: Alberto Donizetti <[email protected]> Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Alberto Donizetti <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 5faa828 commit c8f6135

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/os/os_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"flag"
1111
"fmt"
12+
"internal/race"
1213
"internal/testenv"
1314
"io"
1415
"io/ioutil"
@@ -2579,3 +2580,20 @@ func TestOpenFileKeepsPermissions(t *testing.T) {
25792580
t.Errorf("Stat after OpenFile is %v, should be writable", fi.Mode())
25802581
}
25812582
}
2583+
2584+
// Issue 41474.
2585+
func TestStdoutWriteDoesNotHeapAllocate(t *testing.T) {
2586+
if runtime.GOOS == "js" || runtime.GOOS == "windows" {
2587+
t.Skip("Still heap allocates on js/wasm and windows, but it used to too")
2588+
}
2589+
if race.Enabled {
2590+
t.Skip("Heap allocates in race mode")
2591+
}
2592+
2593+
n := testing.AllocsPerRun(10, func() {
2594+
Stdout.Write([]byte{'h', 'e', 'l', 'l', 'o', '\n'})
2595+
})
2596+
if n != 0 {
2597+
t.Errorf("AllocsPerRun = %v, want 0", n)
2598+
}
2599+
}

0 commit comments

Comments
 (0)