-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add test cases that delete a file during incremental checking #3461
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
Changes from 4 commits
60988f9
1377e26
8e9f3e3
ec03c7e
709d9e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
from mypy.test.data import parse_test_cases, DataDrivenTestCase, DataSuite | ||
from mypy.test.helpers import ( | ||
assert_string_arrays_equal, normalize_error_messages, | ||
testcase_pyversion, update_testcase_output, | ||
retry_on_error, testcase_pyversion, update_testcase_output, | ||
) | ||
from mypy.errors import CompileError | ||
from mypy.options import Options | ||
|
@@ -147,13 +147,17 @@ def run_case_once(self, testcase: DataDrivenTestCase, incremental_step: int = 0) | |
if file.endswith('.' + str(incremental_step)): | ||
full = os.path.join(dn, file) | ||
target = full[:-2] | ||
shutil.copy(full, target) | ||
# Use retries to work around potential flakiness on Windows (AppVeyor). | ||
retry_on_error(lambda: shutil.copy(full, target)) | ||
|
||
# In some systems, mtime has a resolution of 1 second which can cause | ||
# annoying-to-debug issues when a file has the same size after a | ||
# change. We manually set the mtime to circumvent this. | ||
new_time = os.stat(target).st_mtime + 1 | ||
os.utime(target, times=(new_time, new_time)) | ||
for path in testcase.deleted_paths.get(incremental_step, set()): | ||
# Use retries to work around potential flakiness on Windows (AppVeyor). | ||
retry_on_error(lambda: os.remove(path)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test failures seem to be due to the lack of a return type context. Maybe the retry_on_error() function should just take a Callable[[], None]? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the return type to |
||
|
||
# Parse options after moving files (in case mypy.ini is being moved). | ||
options = self.parse_options(original_program_text, testcase, incremental_step) | ||
|
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 was surprised to see that you need to retry the copy too.
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.
A test case might first delete a file and the reintroduce it here, and I suspect that this could then require a retry. Not 100% sure though, but it seems better to be defensive since test flakes are very annoying.