Skip to content

Commit 00295a3

Browse files
committed
endtoend: add an opt-in core context to TestReplay
TestReplay's contexts could only mutate the config, so the coreanalyzer experiment could reach a case only through its own exec.json. Contexts now also name the experiments every case in them runs with, and a new "core" context runs the corpus through the analysis core. The two paths still disagree, so the context is opt-in: it runs only when SQLC_TEST_CORE is set. That gate is an environment variable rather than a test flag because the documented workflow runs the whole module, and a flag defined in one test binary fails every package that does not define it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0161e7oMkzNW9DZMUPtyQibH
1 parent 50b7974 commit 00295a3

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

internal/endtoend/endtoend_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ func BenchmarkExamples(b *testing.B) {
120120
type textContext struct {
121121
Mutate func(*testing.T, string) func(*config.Config)
122122
Enabled func() bool
123+
// Experiments names the experiments every case in this context runs
124+
// with. A case's own SQLCEXPERIMENT is appended to these, so a case can
125+
// still turn one back off with the "no" prefix.
126+
Experiments func() []string
123127
}
124128

125129
func TestReplay(t *testing.T) {
@@ -235,6 +239,16 @@ func TestReplay(t *testing.T) {
235239
return postgresURI != "" || mysqlURI != ""
236240
},
237241
},
242+
"core": {
243+
Mutate: func(t *testing.T, path string) func(*config.Config) { return func(c *config.Config) {} },
244+
Experiments: func() []string { return []string{"coreanalyzer"} },
245+
Enabled: func() bool {
246+
// Running the whole corpus through the analysis core is opt-in
247+
// while the two paths still disagree. The core needs no
248+
// database, so nothing else gates this.
249+
return os.Getenv("SQLC_TEST_CORE") != ""
250+
},
251+
},
238252
}
239253

240254
for name, testctx := range contexts {
@@ -276,9 +290,14 @@ func TestReplay(t *testing.T) {
276290
}
277291
}
278292

293+
experiments := args.Env["SQLCEXPERIMENT"]
294+
if testctx.Experiments != nil {
295+
experiments = strings.Join(append(testctx.Experiments(), experiments), ",")
296+
}
297+
279298
opts := cmd.Options{
280299
Env: cmd.Env{
281-
Experiment: opts.ExperimentFromString(args.Env["SQLCEXPERIMENT"]),
300+
Experiment: opts.ExperimentFromString(experiments),
282301
},
283302
Stderr: &stderr,
284303
MutateConfig: testctx.Mutate(t, path),

0 commit comments

Comments
 (0)