Skip to content

[ci] Try to fix Windows CI failures #18145

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

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions mypy/test/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def __init__(
self.data = data
self.line = line
self.old_cwd: str | None = None
self.tmpdir: tempfile.TemporaryDirectory[str] | None = None
self.tmpdir: str | None = None

def runtest(self) -> None:
if self.skip:
Expand All @@ -323,19 +323,19 @@ def runtest(self) -> None:
save_dir: str | None = self.config.getoption("--save-failures-to", None)
if save_dir:
assert self.tmpdir is not None
target_dir = os.path.join(save_dir, os.path.basename(self.tmpdir.name))
target_dir = os.path.join(save_dir, os.path.basename(self.tmpdir))
print(f"Copying data from test {self.name} to {target_dir}")
if not os.path.isabs(target_dir):
assert self.old_cwd
target_dir = os.path.join(self.old_cwd, target_dir)
shutil.copytree(self.tmpdir.name, target_dir)
shutil.copytree(self.tmpdir, target_dir)
raise

def setup(self) -> None:
parse_test_case(case=self)
self.old_cwd = os.getcwd()
self.tmpdir = tempfile.TemporaryDirectory(prefix="mypy-test-")
os.chdir(self.tmpdir.name)
self.tmpdir = tempfile.mkdtemp(prefix="mypy-test-")
os.chdir(self.tmpdir)
os.mkdir(test_temp_dir)

# Precalculate steps for find_steps()
Expand Down Expand Up @@ -371,10 +371,7 @@ def teardown(self) -> None:
if self.old_cwd is not None:
os.chdir(self.old_cwd)
if self.tmpdir is not None:
try:
self.tmpdir.cleanup()
except OSError:
pass
shutil.rmtree(self.tmpdir, ignore_errors=True)
self.old_cwd = None
self.tmpdir = None

Expand Down
8 changes: 4 additions & 4 deletions mypy/test/testfinegrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
if messages:
a.extend(normalize_messages(messages))

assert testcase.tmpdir
a.extend(self.maybe_suggest(step, server, main_src, testcase.tmpdir.name))
assert testcase.tmpdir is not None
a.extend(self.maybe_suggest(step, server, main_src, testcase.tmpdir))
a.extend(self.maybe_inspect(step, server, main_src))

if server.fine_grained_manager:
Expand Down Expand Up @@ -248,8 +248,8 @@ def perform_step(
new_messages = normalize_messages(new_messages)

a = new_messages
assert testcase.tmpdir
a.extend(self.maybe_suggest(step, server, main_src, testcase.tmpdir.name))
assert testcase.tmpdir is not None
a.extend(self.maybe_suggest(step, server, main_src, testcase.tmpdir))
a.extend(self.maybe_inspect(step, server, main_src))

return a, triggered
Expand Down
Loading