Skip to content
Merged
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: 10 additions & 5 deletions tests/test_run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,11 @@ def test_no_wineserver_is_one_line_and_the_run_goes_on(self):
self.assertIn("[PASS] ok", out)

def timed(self, name, *, props=None, code=0, sleep=0.3):
"""A test that logs when it starts and ends, to see which tests overlapped."""
"""A test that logs when it starts and ends, to see which tests overlapped. Each test has its own log:
appends from several processes to one file are not atomic on Windows, so a shared log loses or merges
lines when tests run at the same time."""
timing = self.root / "timing"
timing.mkdir(exist_ok=True)
(self.artifact / f"{name}.py").write_text(
"import os, sys, time\n"
"log = os.environ['TIMING_LOG']\n"
Expand All @@ -610,14 +614,15 @@ def timed(self, name, *, props=None, code=0, sleep=0.3):
f"open(log, 'a').write('{name} end %r\\n' % time.monotonic())\n"
f"sys.exit({code})\n", encoding="utf-8", newline="\n")
props = dict(props or {})
props["ENVIRONMENT"] = ["TIMING_LOG=" + str(self.root / "timing.log")]
props["ENVIRONMENT"] = ["TIMING_LOG=" + str(timing / f"{name}.log")]
return ctest_entry(name, self.command(f"{name}.py"), props)

def intervals(self):
spans: dict[str, list[float]] = {}
for line in (self.root / "timing.log").read_text(encoding="utf-8").splitlines():
name, _, when = line.split()
spans.setdefault(name, []).append(float(when))
for log in sorted((self.root / "timing").glob("*.log")):
for line in log.read_text(encoding="utf-8").splitlines():
name, _, when = line.split()
spans.setdefault(name, []).append(float(when))
return spans

@staticmethod
Expand Down