This test only compiles examples, but has coverage over all examples provided. This ensures we ship at least syntactically correct examples.
(t *testing.T)
| 128 | // This test only compiles examples, but has coverage over all examples |
| 129 | // provided. This ensures we ship at least syntactically correct examples. |
| 130 | func 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 | |
| 149 | func BenchmarkProgram(b *testing.B) { |
| 150 | for _, bm := range exampleProgramTests { |
nothing calls this directly
no test coverage detected