MCPcopy
hub / github.com/google/mtail / TestCompileExamplePrograms

Function TestCompileExamplePrograms

internal/mtail/examples_integration_test.go:130–147  ·  view source on GitHub ↗

This test only compiles examples, but has coverage over all examples provided. This ensures we ship at least syntactically correct examples.

(t *testing.T)

Source from the content-addressed store, hash-verified

128// This test only compiles examples, but has coverage over all examples
129// provided. This ensures we ship at least syntactically correct examples.
130func TestCompileExamplePrograms(t *testing.T) {
131 testutil.SkipIfShort(t)
132 matches, err := filepath.Glob("../../examples/*.mtail")
133 testutil.FatalIfErr(t, err)
134 for _, tc := range matches {
135 tc := tc
136 name := filepath.Base(tc)
137 t.Run(name, func(t *testing.T) {
138 ctx, cancel := context.WithCancel(context.Background())
139 s := metrics.NewStore()
140 mtail, err := mtail.New(ctx, s, mtail.ProgramPath(tc), mtail.CompileOnly, mtail.OmitMetricSource, mtail.DumpAstTypes, mtail.DumpBytecode)
141 testutil.FatalIfErr(t, err)
142 // Ensure that run shuts down for CompileOnly
143 testutil.FatalIfErr(t, mtail.Run())
144 cancel()
145 })
146 }
147}
148
149func BenchmarkProgram(b *testing.B) {
150 for _, bm := range exampleProgramTests {

Callers

nothing calls this directly

Calls 6

SkipIfShortFunction · 0.92
FatalIfErrFunction · 0.92
NewStoreFunction · 0.92
NewFunction · 0.92
ProgramPathTypeAlias · 0.92
RunMethod · 0.45

Tested by

no test coverage detected