enableExperimentForTest enables the experiment behind pointer e for the duration of test t and sub-tests, with the experiment being restored to its previous state when tests complete. Typically experiments are controlled via TASK_X_ env vars, but we cannot use those in tests because the experiment
(t *testing.T, e *experiments.Experiment, val int)
| 3039 | // Typically experiments are controlled via TASK_X_ env vars, but we cannot use those in tests |
| 3040 | // because the experiment settings are parsed during experiments.init(), before any tests run. |
| 3041 | func enableExperimentForTest(t *testing.T, e *experiments.Experiment, val int) { |
| 3042 | t.Helper() |
| 3043 | prev := *e |
| 3044 | *e = experiments.Experiment{ |
| 3045 | Name: prev.Name, |
| 3046 | AllowedValues: []int{val}, |
| 3047 | Value: val, |
| 3048 | } |
| 3049 | t.Cleanup(func() { *e = prev }) |
| 3050 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…