-
Notifications
You must be signed in to change notification settings - Fork 533
Do not allow changes to ENV to leak from test to test #403
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
Conversation
Signed-off-by: James Couball <jcouball@yahoo.com>
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.
Looks good, bonus points for fixing the file with an obvious typo in the file name! 👍
ensure | ||
Git::Lib::ENV_VARIABLE_NAMES.each { |k| ENV[k] = saved_env[k] } | ||
end | ||
end |
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 reminds me about my dislike for test-unit
; with rspec
, this could easily be done using an around {}
block instead.)
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.
I prefer rspec
for the structure it makes possible. I suspect that others don't care for rspec
because that structure comes with additional complexity and a steeper learning curve.
That said, I respect any project that has tests no matter what framework!
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.
Comparing rspec
to other test frameworks in general, like testng
in Java, I think the fact that you can actually "group" and structure your tests with rspec
is a big boon. It's one of the things I'm missing from no longer using it actually.
If you feel like rewriting the tests to use rspec
, I clearly wouldn't object, but this is definitely not an obligation in any way. 😃
Signed-off-by: James Couball <jcouball@yahoo.com>Signed-off-by: Agora Security <github@agora-security.com>
Your checklist for this pull request
🚨Please review the guidelines for contributing to this repository.
Description
Currently, the TestThreadSafety test case occasionally fails when executed as part of the build with this error:
the important part is:
It can be made to fail consistently by greatly increasing the thread count. 50 threads on my test machine makes if fail every time.
I found that other tests alter the ENV global variable which makes the test_thread_safety test suite fail.
This change makes it so that tests always restore ENV to its original state.
I think this is a short term fix. A better fix would be to pass the desired environment into any method that creates a Git::Base (defaulting to a copy of ENV) and not use the ENV global through out the code.
Signed-off-by: James Couball jcouball@yahoo.com