This test checks that calls are not inlined when the call appears in a specific test of the function. (Even deprecated functions deserve tests.) A test is specific if either: - it is named for the symbol (e.g TestF -> F) (#76190), or - its filename a_test.go matches the declaring file a.go (#79272). Symbol name variants: - functions (TestF) vs methods (TestT_F) - optional comment suffixes (TestSYMBOL_comment) - in-package test vs external test - test of same or different package from symbol -- go.mod -- module example.com -- a/a.go -- package a //go:fix inline func F() { print("F") } // want F:"goFixInline a.F" //go:fix inline func G() { print("G") } // want G:"goFixInline a.G" type T int //go:fix inline func (T) F() { print("T.F") } // want F:`goFixInline \(a.T\).F` //go:fix inline func (T) G() { print("T.G") } // want G:`goFixInline \(a.T\).G` //go:fix inline type A = T // want A:`goFixInline alias` //go:fix inline const K = One // want K:`goFixInline const "example.com/a".One` const One = 1 -- a/a_test.go -- package a import "testing" func TestWithAnyName(t *testing.T) { F() // not inlined G() // not inlined print(K) // not inlined var _ A // not inlined } -- a/other_test.go -- package a import "testing" func Test(t *testing.T) { F() // want "Call of a.F should be inlined" G() // want "Call of a.G should be inlined" print(K) // want "Constant K should be inlined" var _ A // want "Type alias A should be inlined" } func TestG_comment(t *testing.T) { F() // want "Call of a.F should be inlined" G() // not inlined } func TestT_F(t *testing.T) { T(0).F() // not inlined T(0).G() // want `Call of \(a.T\).G should be inlined` } func TestT_G(t *testing.T) { T(0).F() // want `Call of \(a.T\).F should be inlined` T(0).G() // not inlined } func TestK(t *testing.T) { print(K) // not inlined } func TestA(t *testing.T) { var _ A // not inlined } -- a/a_test.go.golden -- package a import "testing" func TestF(t *testing.T) { F() // not inlined print("G") // want "Call of a.G should be inlined" } func TestG_comment(t *testing.T) { print("F") // want "Call of a.F should be inlined" G() // not inlined } func TestT_F(t *testing.T) { T(0).F() // not inlined print("T.G") // want `Call of \(a.T\).G should be inlined` } func TestT_G(t *testing.T) { print("T.F") // want `Call of \(a.T\).F should be inlined` T(0).G() // not inlined } -- a/other_test.go.golden -- package a import "testing" func Test(t *testing.T) { print("F") // want "Call of a.F should be inlined" print("G") // want "Call of a.G should be inlined" print(One) // want "Constant K should be inlined" var _ T // want "Type alias A should be inlined" } func TestG_comment(t *testing.T) { print("F") // want "Call of a.F should be inlined" G() // not inlined } func TestT_F(t *testing.T) { T(0).F() // not inlined print("T.G") // want `Call of \(a.T\).G should be inlined` } func TestT_G(t *testing.T) { print("T.F") // want `Call of \(a.T\).F should be inlined` T(0).G() // not inlined } func TestK(t *testing.T) { print(K) // not inlined } func TestA(t *testing.T) { var _ A // not inlined } -- a/a_x_test.go -- package a_test import ( "example.com/a" "testing" ) func TestF(t *testing.T) { a.F() // not inlined a.G() // want "Call of a.G should be inlined" } func TestG_comment(t *testing.T) { a.F() // want "Call of a.F should be inlined" a.G() // not inlined } func TestT_F(t *testing.T) { a.T(0).F() // not inlined a.T(0).G() // want `Call of \(a.T\).G should be inlined` } func TestT_G(t *testing.T) { a.T(0).F() // want `Call of \(a.T\).F should be inlined` a.T(0).G() // not inlined } -- a/a_x_test.go.golden -- package a_test import ( "example.com/a" "testing" ) func TestF(t *testing.T) { a.F() // not inlined print("G") // want "Call of a.G should be inlined" } func TestG_comment(t *testing.T) { print("F") // want "Call of a.F should be inlined" a.G() // not inlined } func TestT_F(t *testing.T) { a.T(0).F() // not inlined print("T.G") // want `Call of \(a.T\).G should be inlined` } func TestT_G(t *testing.T) { print("T.F") // want `Call of \(a.T\).F should be inlined` a.T(0).G() // not inlined } -- b/b_test.go -- package b_test import ( "example.com/a" "testing" ) func TestF(t *testing.T) { a.F() // want "Call of a.F should be inlined" } -- b/b_test.go.golden -- package b_test import ( "testing" ) func TestF(t *testing.T) { print("F") // want "Call of a.F should be inlined" }