-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store experiments in contexts #2316
Conversation
e90c6e3
to
c9c238c
Compare
e39c123
to
95fa8de
Compare
This is ready, if anyone wants to poke at it. |
95fa8de
to
1bbe285
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me so happy!
Just mainly, I think the move to internal can happen now. It's supposedly imported by ~~~2~~ 4 libraries, but that just looks like a fork of the agent.
Even if it's imported by real modules, there's legitimate reason modules outside the agent to use it.
@@ -29,10 +29,10 @@ var commitPattern = bintest.MatchPattern(`(?ms)\Acommit [0-9a-f]+\nabbrev-commit | |||
const gitShowFormatArg = "--format=commit %H%nabbrev-commit %h%nAuthor: %an <%ae>%n%n%w(0,4,4)%B" | |||
|
|||
func TestWithResolvingCommitExperiment(t *testing.T) { | |||
// t.Parallel() cannot be used with experiments.Enable() | |||
defer experiments.EnableWithUndo(experiments.ResolveCommitAfterCheckout)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, not needing this is a win too!
// This context needs to be stored here in order to pass experiments to tests, | ||
// because testing.M can only Run (without passing arguments or context). | ||
// In ordinary code, pass contexts as arguments! | ||
var mainCtx = context.Background() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1bbe285
to
a599ede
Compare
It was missing `tc := tc` in the loop. With that added, `post-checkout` failed consistently rather than rarely. (Looks like `post-checkout` shouldn't upload the artifact.)
a599ede
to
5be1f98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💜
The main change is to associate experiments with contexts (as values). Enabling or disabling an experiment creates a new context.
Most code has context plumbed through correctly, so adopting it wasn't too hard. The bulk of the updates are to tests.
But now that experiments is not a "global variable", we can parallelise more tests!