Documentation
¶
Overview ¶
Package codegentest provides utilities for testing generators.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TestData = analysistest.TestData
Functions ¶
func Golden ¶
Golden compares the results with golden files. Golden creates read a golden file which name is codegen.Generator.Name + ".golden". The golden file is stored in same directory of the package. If Golden cannot find a golden file or the result of Generator test is not same with the golden, Golden reports error via *testing.T. If update is true, golden files would be updated.
var flagUpdate bool
func TestMain(m *testing.M) {
flag.BoolVar(&flagUpdate, "update", false, "update the golden files")
flag.Parse()
os.Exit(m.Run())
}
func TestGenerator(t *testing.T) {
rs := codegentest.Run(t, codegentest.TestData(), example.Generator, "example")
codegentest.Golden(t, rs, flagUpdate)
}
Types ¶
type Result ¶
type Result struct {
Dir string
Pass *codegen.Pass
Facts map[types.Object][]analysis.Fact
Err error
Output *bytes.Buffer
}
A Result holds the result of applying a generator to a package.
type Testing ¶
type Testing = analysistest.Testing
Click to show internal directories.
Click to hide internal directories.