-
Notifications
You must be signed in to change notification settings - Fork 202
[tests] Add missing calls to super
in setup
and teardown
methods
#949
Conversation
super
in setup
methodssuper
in setup
and teardown
methods
project_context('project') | ||
::ShopifyCli::Project.clear | ||
super | ||
end | ||
|
||
def teardown | ||
unless @minitest_ext_setup_called |
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 used this to find the missing places.
@@ -14,6 +14,7 @@ def setup | |||
def teardown | |||
@context.setenv('GEM_HOME', nil) | |||
@context.setenv('GEM_PATH', nil) | |||
super |
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.
For missing super
calls in teardown
, I don't know of an automated way of finding these, I just manually checked them.
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 is a good question. If minitest creates a new test instance on every run there won't be any state left over on subsequent runs, so the only place I can think of would be to check the flag during garbage collection (if that's even possible).
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.
We could maybe use an at_exit
hook.
But I'd like for this to be a stopgap measure, and use a linter instead.
I've added a entry to the minitest style guide:
rubocop/minitest-style-guide#35
So the next step would be to add it in rubocop-minitest:
rubocop/rubocop-minitest#111
c8947c8
to
468874b
Compare
@@ -14,6 +14,7 @@ def setup | |||
def teardown | |||
@context.setenv('GEM_HOME', nil) | |||
@context.setenv('GEM_PATH', nil) | |||
super |
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 is a good question. If minitest creates a new test instance on every run there won't be any state left over on subsequent runs, so the only place I can think of would be to check the flag during garbage collection (if that's even possible).
This can lead to intermittent failures depending on the order tests are run in.