robotcode-runner 2.9.0.dev124__tar.gz → 2.9.0.dev180__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/PKG-INFO +5 -5
  2. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/pyproject.toml +4 -4
  3. robotcode_runner-2.9.0.dev180/src/robotcode/runner/__version__.py +1 -0
  4. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/_markdown.py +11 -52
  5. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/discover/discover.py +3 -3
  6. robotcode_runner-2.9.0.dev180/src/robotcode/runner/cli/results/_compare.py +479 -0
  7. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/results/_html.py +5 -5
  8. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/results/_models.py +162 -0
  9. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/results/_render.py +279 -12
  10. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/results/results.py +659 -25
  11. robotcode_runner-2.9.0.dev124/src/robotcode/runner/__version__.py +0 -1
  12. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/.gitignore +0 -0
  13. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/README.md +0 -0
  14. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/__init__.py +0 -0
  15. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/__init__.py +0 -0
  16. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/_robot_version.py +0 -0
  17. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/_search.py +0 -0
  18. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/discover/__init__.py +0 -0
  19. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/discover/_models.py +0 -0
  20. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/discover/_render.py +0 -0
  21. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/libdoc.py +0 -0
  22. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/rebot.py +0 -0
  23. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/results/__init__.py +0 -0
  24. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/robot.py +0 -0
  25. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/cli/testdoc.py +0 -0
  26. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/hooks.py +0 -0
  27. {robotcode_runner-2.9.0.dev124 → robotcode_runner-2.9.0.dev180}/src/robotcode/runner/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: robotcode-runner
3
- Version: 2.9.0-dev.124
3
+ Version: 2.9.0-dev.180
4
4
  Summary: RobotCode runner for Robot Framework
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -26,10 +26,10 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
26
26
  Classifier: Topic :: Utilities
27
27
  Classifier: Typing :: Typed
28
28
  Requires-Python: >=3.10
29
- Requires-Dist: robotcode-modifiers==2.9.0-dev.124
30
- Requires-Dist: robotcode-plugin==2.9.0-dev.124
31
- Requires-Dist: robotcode-robot==2.9.0-dev.124
32
- Requires-Dist: robotcode==2.9.0-dev.124
29
+ Requires-Dist: robotcode-modifiers==2.9.0-dev.180
30
+ Requires-Dist: robotcode-plugin==2.9.0-dev.180
31
+ Requires-Dist: robotcode-robot==2.9.0-dev.180
32
+ Requires-Dist: robotcode==2.9.0-dev.180
33
33
  Requires-Dist: robotframework>=5.0.0
34
34
  Provides-Extra: html
35
35
  Requires-Dist: html-to-markdown>=3.18; extra == 'html'
@@ -30,10 +30,10 @@ classifiers = [
30
30
  dynamic = ["version"]
31
31
  dependencies = [
32
32
  "robotframework>=5.0.0",
33
- "robotcode-robot==2.9.0-dev.124",
34
- "robotcode-modifiers==2.9.0-dev.124",
35
- "robotcode-plugin==2.9.0-dev.124",
36
- "robotcode==2.9.0-dev.124",
33
+ "robotcode-robot==2.9.0-dev.180",
34
+ "robotcode-modifiers==2.9.0-dev.180",
35
+ "robotcode-plugin==2.9.0-dev.180",
36
+ "robotcode==2.9.0-dev.180",
37
37
  ]
38
38
 
39
39
  [project.optional-dependencies]
@@ -0,0 +1 @@
1
+ __version__ = "2.9.0-dev.180"
@@ -142,7 +142,7 @@ def timing_suffix(
142
142
  *,
143
143
  show_timing: bool,
144
144
  ) -> str:
145
- """Italic `` _(13:34:23 · 12 ms)_ `` suffix or an empty string."""
145
+ """Italic `` _(13:34:23, 12 ms)_ `` suffix or an empty string."""
146
146
  parts: List[str] = []
147
147
  if show_timing and start_time:
148
148
  parts.append(fmt_time_only(start_time))
@@ -150,56 +150,17 @@ def timing_suffix(
150
150
  parts.append(fmt_elapsed(elapsed_seconds))
151
151
  if not parts:
152
152
  return ""
153
- return f" _({' · '.join(parts)})_"
153
+ return f" _({', '.join(parts)})_"
154
154
 
155
155
 
156
156
  # ---------------------------------------------------------------------------
157
- # Status icons + bold word
157
+ # Bold status word
158
158
  # ---------------------------------------------------------------------------
159
159
 
160
160
 
161
- STATUS_ICONS = {
162
- "PASS": "✅",
163
- "FAIL": "❌",
164
- "SKIP": "⏭",
165
- "NOT RUN": "⏸",
166
- "NOT SET": "⚪",
167
- }
168
-
169
-
170
- # Display-width adjustment for the (small, fixed) emoji set the renderer
171
- # emits. Most emoji codepoints render as two terminal cells but `len()`
172
- # counts them as one — so naive padding under-pads any row containing an
173
- # emoji. We explicitly track the icons we use rather than a regex range,
174
- # because the misc-technical block (U+2300..U+23FF) holds both
175
- # double-width emoji (`⏭`, `⏸`) and single-width geometric shapes —
176
- # a range-based heuristic would either miss our icons or misclassify
177
- # unrelated content.
178
- DOUBLE_WIDTH_ICONS: "frozenset[str]" = frozenset(STATUS_ICONS.values())
179
-
180
-
181
- def status_icon(status: str) -> str:
182
- return STATUS_ICONS.get(status.upper(), "")
183
-
184
-
185
- def bold_status(status: str, *, icon: bool = True) -> str:
186
- """Icon + bold status word: ``❌ **FAIL**``. The icon gives a scanable
187
- visual marker for terminal / Slack / GitHub paste; the bold word keeps
188
- the status readable for screen readers and stays meaningful in
189
- rendering targets that don't paint emoji. Pass ``icon=False`` to
190
- suppress the emoji (e.g. when the cell is followed by a separator or
191
- you want to stay strictly ASCII)."""
192
- word = f"**{status.upper()}**"
193
- if icon:
194
- ic = status_icon(status)
195
- if ic:
196
- return f"{ic} {word}"
197
- return word
198
-
199
-
200
- def display_width(text: str) -> int:
201
- """Source length plus one extra column per known double-width emoji."""
202
- return len(text) + sum(1 for ch in text if ch in DOUBLE_WIDTH_ICONS)
161
+ def bold_status(status: str) -> str:
162
+ """Bold status word: ``**FAIL**``. Plain ASCII, so the output survives any stream encoding."""
163
+ return f"**{status.upper()}**"
203
164
 
204
165
 
205
166
  # ---------------------------------------------------------------------------
@@ -243,20 +204,18 @@ def md_table(headers: List[str], rows: List[List[str]], *, aligns: Optional[List
243
204
  aligns = ["left"] * len(headers)
244
205
 
245
206
  escaped_rows = [[md_pipe(cell) for cell in r] for r in rows]
246
- # Per-column visual width = max(header, all cells). Display-width-aware
247
- # so emoji cells (counted as 2 terminal columns) don't under-pad the
248
- # column. Floor at 3 so the `---` separator stays valid for narrow
249
- # columns like a one-digit count.
207
+ # Per-column width = max(header, all cells). Floor at 3 so the `---`
208
+ # separator stays valid for narrow columns like a one-digit count.
250
209
  widths: List[int] = []
251
210
  for col, header in enumerate(headers):
252
- w = display_width(header)
211
+ w = len(header)
253
212
  for r in escaped_rows:
254
213
  if col < len(r):
255
- w = max(w, display_width(r[col]))
214
+ w = max(w, len(r[col]))
256
215
  widths.append(max(w, 3))
257
216
 
258
217
  def _pad(text: str, width: int, align: str) -> str:
259
- extra = width - display_width(text)
218
+ extra = width - len(text)
260
219
  if extra <= 0:
261
220
  return text
262
221
  if align == "right":
@@ -81,9 +81,9 @@ DISCOVER_SEARCH_OPTIONS = [
81
81
  "timeout, any tag (normalisation-aware), test metadata names and "
82
82
  "values, the parent suite's Documentation / Metadata, or anything "
83
83
  "inside the test body "
84
- "— keyword names, keyword arguments, assigned variables, "
84
+ "(keyword names, keyword arguments, assigned variables, "
85
85
  "FOR/WHILE/IF conditions, VAR/RETURN values, EXCEPT patterns, "
86
- "GROUP names. Mutually exclusive with `--search-regex`."
86
+ "GROUP names). Mutually exclusive with `--search-regex`."
87
87
  ),
88
88
  ),
89
89
  click.option(
@@ -92,7 +92,7 @@ DISCOVER_SEARCH_OPTIONS = [
92
92
  metavar="PATTERN",
93
93
  default=None,
94
94
  help=(
95
- "Only include items where PATTERN (Python regex, case-sensitive — "
95
+ "Only include items where PATTERN (Python regex, case-sensitive; "
96
96
  "prefix with `(?i)` for case-insensitive) matches any of the "
97
97
  "same targets as `--search`. Mutually exclusive with `--search`."
98
98
  ),
@@ -0,0 +1,479 @@
1
+ """Computations of `robotcode results compare`.
2
+
3
+ `results.py` reduces every result file to a `RunSnapshot` right after it is
4
+ loaded and filtered; everything here works on those snapshots, so the views
5
+ can be computed and tested without the CLI and without holding the parsed
6
+ result trees.
7
+ """
8
+
9
+ import os
10
+ import re
11
+ import statistics
12
+ from dataclasses import dataclass, field
13
+ from itertools import pairwise
14
+ from pathlib import Path
15
+ from typing import Dict, Iterable, List, Optional, Sequence, Tuple
16
+
17
+ from ._models import Counts, StatsGroup
18
+
19
+ # One ASCII character per status, so that the status of a test over the runs
20
+ # is a short string and stays printable on every console.
21
+ STATUS_CHARS = {"PASS": "P", "FAIL": "F", "SKIP": "S", "NOT RUN": "N"}
22
+ MISSING_CHAR = "-"
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class RunArgument:
27
+ path: Path
28
+ name: Optional[str] = None
29
+
30
+
31
+ def split_run_argument(text: str) -> RunArgument:
32
+ """Split `NAME=PATH` into its name and path.
33
+
34
+ An argument that names an existing file is always a path, even if it
35
+ contains `=`. So is one whose text before the first `=` contains a path
36
+ separator, as in `results/run=1.xml`.
37
+ """
38
+ if "=" not in text or Path(text).is_file():
39
+ return RunArgument(Path(text))
40
+ name, path = text.split("=", 1)
41
+ if "/" in name or os.sep in name:
42
+ return RunArgument(Path(text))
43
+ return RunArgument(Path(path), name)
44
+
45
+
46
+ @dataclass
47
+ class RunTest:
48
+ full_name: str
49
+ status: str
50
+ elapsed_seconds: Optional[float] = None
51
+ message: str = ""
52
+ source: Optional[str] = None
53
+ lineno: Optional[int] = None
54
+
55
+
56
+ @dataclass
57
+ class ExecutionMessage:
58
+ level: str
59
+ text: str
60
+
61
+
62
+ @dataclass
63
+ class RunSnapshot:
64
+ """What the views of `compare` need from one result file."""
65
+
66
+ argument: RunArgument
67
+ status: str
68
+ counts: Counts
69
+ elapsed_seconds: Optional[float] = None
70
+ start_time: Optional[str] = None
71
+ # The start that orders the run for `--run-order start-time`: the top suite's, else its earliest child's.
72
+ order_time: Optional[str] = None
73
+ generator: Optional[str] = None
74
+ generation_time: Optional[str] = None
75
+ metadata: Dict[str, str] = field(default_factory=dict)
76
+ tests: Dict[str, RunTest] = field(default_factory=dict)
77
+ suite_elapsed: Dict[str, Optional[float]] = field(default_factory=dict)
78
+ messages: List[ExecutionMessage] = field(default_factory=list)
79
+ # dimension ("tag" | "suite") -> group name -> counts and elapsed of that group in this run
80
+ buckets: Dict[str, Dict[str, StatsGroup]] = field(default_factory=dict)
81
+
82
+
83
+ @dataclass
84
+ class ComparedRun:
85
+ number: int
86
+ snapshot: RunSnapshot
87
+
88
+ @property
89
+ def name(self) -> Optional[str]:
90
+ return self.snapshot.argument.name
91
+
92
+
93
+ @dataclass
94
+ class RunGroup:
95
+ """Runs that are compared with each other; a single group without `--group-by-metadata`."""
96
+
97
+ name: Optional[str]
98
+ runs: List[ComparedRun]
99
+
100
+
101
+ def arrange_runs(
102
+ snapshots: Sequence[RunSnapshot],
103
+ *,
104
+ by_start_time: bool = False,
105
+ group_metadata: Optional[str] = None,
106
+ last: Optional[int] = None,
107
+ ) -> List[RunGroup]:
108
+ """Order, group and number the runs, then keep the last ones.
109
+
110
+ The numbers are given before `last` is applied, so a run keeps its
111
+ number with and without `--last`.
112
+ """
113
+ ordered = list(snapshots)
114
+ if by_start_time:
115
+ # stable: runs with the same start, and runs without one, keep the order of the arguments
116
+ ordered.sort(key=lambda s: (s.order_time is None, s.order_time or ""))
117
+
118
+ names: List[Optional[str]] = []
119
+ members: Dict[Optional[str], List[RunSnapshot]] = {}
120
+ for snapshot in ordered:
121
+ key = snapshot.metadata.get(group_metadata) if group_metadata is not None else None
122
+ if key not in members:
123
+ names.append(key)
124
+ members[key] = []
125
+ members[key].append(snapshot)
126
+
127
+ groups: List[RunGroup] = []
128
+ number = 0
129
+ for key in names:
130
+ runs: List[ComparedRun] = []
131
+ for snapshot in members[key]:
132
+ number += 1
133
+ runs.append(ComparedRun(number, snapshot))
134
+ if last is not None:
135
+ runs = runs[-last:]
136
+ groups.append(RunGroup(key, runs))
137
+ return groups
138
+
139
+
140
+ def all_runs(groups: Sequence[RunGroup]) -> List[ComparedRun]:
141
+ return [run for group in groups for run in group.runs]
142
+
143
+
144
+ def sum_counts(counts: Iterable[Counts]) -> Counts:
145
+ total = Counts()
146
+ for c in counts:
147
+ total.total += c.total
148
+ total.passed += c.passed
149
+ total.failed += c.failed
150
+ total.skipped += c.skipped
151
+ total.not_run += c.not_run
152
+ return total
153
+
154
+
155
+ def sum_elapsed(values: Iterable[Optional[float]]) -> Optional[float]:
156
+ present = [v for v in values if v is not None]
157
+ return sum(present) if present else None
158
+
159
+
160
+ # ---------------------------------------------------------------------------
161
+ # Status of each test over the runs
162
+ # ---------------------------------------------------------------------------
163
+
164
+
165
+ def status_string(statuses: Sequence[Optional[str]]) -> str:
166
+ """One character per run, `-` for a run without the test."""
167
+ return "".join(STATUS_CHARS.get(s, s[:1]) if s is not None else MISSING_CHAR for s in statuses)
168
+
169
+
170
+ def pass_fail_changes(statuses: Sequence[Optional[str]]) -> int:
171
+ """How often the status changes between passed and failed, skipping every other status and missing runs."""
172
+ sequence = [s for s in statuses if s in ("PASS", "FAIL")]
173
+ return sum(1 for a, b in pairwise(sequence) if a != b)
174
+
175
+
176
+ def is_flaky(statuses: Sequence[Optional[str]]) -> bool:
177
+ """Two or more changes between passed and failed; a single change is a new failure or a fix."""
178
+ return pass_fail_changes(statuses) >= 2
179
+
180
+
181
+ def failing_since(statuses: Sequence[Optional[str]], numbers: Sequence[int]) -> Optional[int]:
182
+ """The number of the run where the uninterrupted failures up to the last run that had the test began.
183
+
184
+ Runs without the test don't interrupt the series. `None` when the test
185
+ didn't fail in the last run that had it.
186
+ """
187
+ present = [(n, s) for n, s in zip(numbers, statuses) if s is not None]
188
+ if not present or present[-1][1] != "FAIL":
189
+ return None
190
+ since = present[-1][0]
191
+ for n, s in reversed(present):
192
+ if s != "FAIL":
193
+ break
194
+ since = n
195
+ return since
196
+
197
+
198
+ @dataclass
199
+ class StatusHistory:
200
+ """The status of one test in the runs of one group."""
201
+
202
+ group: Optional[str]
203
+ statuses: List[Optional[str]]
204
+ numbers: List[int]
205
+
206
+ @property
207
+ def runs(self) -> int:
208
+ return sum(1 for s in self.statuses if s is not None)
209
+
210
+ @property
211
+ def failed(self) -> int:
212
+ return sum(1 for s in self.statuses if s == "FAIL")
213
+
214
+ @property
215
+ def flaky(self) -> bool:
216
+ return is_flaky(self.statuses)
217
+
218
+ @property
219
+ def failing_since(self) -> Optional[int]:
220
+ return failing_since(self.statuses, self.numbers)
221
+
222
+
223
+ @dataclass
224
+ class StatusRow:
225
+ full_name: str
226
+ histories: List[StatusHistory]
227
+ test: RunTest
228
+
229
+ @property
230
+ def statuses(self) -> List[Optional[str]]:
231
+ return [s for h in self.histories for s in h.statuses]
232
+
233
+ @property
234
+ def failed(self) -> int:
235
+ return sum(h.failed for h in self.histories)
236
+
237
+
238
+ def status_rows(groups: Sequence[RunGroup]) -> List[StatusRow]:
239
+ """Every test that failed in at least one run, the most failed first, then by name."""
240
+ # every test name, in the order the tests first appear
241
+ names = dict.fromkeys(name for run in all_runs(groups) for name in run.snapshot.tests)
242
+
243
+ rows: List[StatusRow] = []
244
+ for name in names:
245
+ histories = [
246
+ StatusHistory(
247
+ group.name,
248
+ [t.status if (t := run.snapshot.tests.get(name)) is not None else None for run in group.runs],
249
+ [run.number for run in group.runs],
250
+ )
251
+ for group in groups
252
+ ]
253
+ row = StatusRow(name, histories, _last_snapshot(groups, name))
254
+ if row.failed:
255
+ rows.append(row)
256
+ rows.sort(key=lambda r: (-r.failed, r.full_name))
257
+ return rows
258
+
259
+
260
+ def _last_snapshot(groups: Sequence[RunGroup], name: str) -> RunTest:
261
+ """The test as the last run that had it recorded it, for its source and line."""
262
+ return next(t for run in reversed(all_runs(groups)) if (t := run.snapshot.tests.get(name)) is not None)
263
+
264
+
265
+ # ---------------------------------------------------------------------------
266
+ # The same failure over tests and runs
267
+ # ---------------------------------------------------------------------------
268
+
269
+ _NUMBER_RE = re.compile(r"\d+")
270
+
271
+
272
+ def message_key(text: str) -> str:
273
+ """Two messages are the same when their keys are equal: every number replaced by `#`, whitespace collapsed."""
274
+ return " ".join(_NUMBER_RE.sub("#", text).split())
275
+
276
+
277
+ @dataclass
278
+ class FailureRow:
279
+ key: str
280
+ message: str
281
+ tests: List[str]
282
+ # number of tests with this message, one entry per shown run
283
+ per_run: List[int]
284
+ # the number of the first run with this message, one entry per group
285
+ first_runs: List[Optional[int]]
286
+
287
+
288
+ def failure_rows(groups: Sequence[RunGroup]) -> List[FailureRow]:
289
+ runs = all_runs(groups)
290
+ rows: Dict[str, FailureRow] = {}
291
+ for index, run in enumerate(runs):
292
+ for test in run.snapshot.tests.values():
293
+ if test.status != "FAIL" or not test.message:
294
+ continue
295
+ key = message_key(test.message)
296
+ row = rows.get(key)
297
+ if row is None:
298
+ row = rows[key] = FailureRow(key, test.message, [], [0] * len(runs), [None] * len(groups))
299
+ row.per_run[index] += 1
300
+ if test.full_name not in row.tests:
301
+ row.tests.append(test.full_name)
302
+
303
+ for row in rows.values():
304
+ index = 0
305
+ for g, group in enumerate(groups):
306
+ for run in group.runs:
307
+ if row.first_runs[g] is None and row.per_run[index]:
308
+ row.first_runs[g] = run.number
309
+ index += 1
310
+
311
+ result = list(rows.values())
312
+ result.sort(key=lambda r: (-len(r.tests), r.key))
313
+ return result
314
+
315
+
316
+ # ---------------------------------------------------------------------------
317
+ # Growth of elapsed times
318
+ # ---------------------------------------------------------------------------
319
+
320
+
321
+ @dataclass
322
+ class Growth:
323
+ full_name: str
324
+ group: Optional[str]
325
+ median_seconds: float
326
+ last_seconds: float
327
+
328
+ @property
329
+ def growth_seconds(self) -> float:
330
+ return self.last_seconds - self.median_seconds
331
+
332
+ @property
333
+ def growth_percent(self) -> Optional[float]:
334
+ if self.median_seconds <= 0:
335
+ return None
336
+ return self.growth_seconds / self.median_seconds * 100.0
337
+
338
+
339
+ def growth_of(times: Sequence[Optional[float]]) -> Optional[Tuple[float, float]]:
340
+ """`(median before, last)` over the runs that had the item; `None` for fewer than two such runs."""
341
+ present = [t for t in times if t is not None]
342
+ if len(present) < 2:
343
+ return None
344
+ return float(statistics.median(present[:-1])), present[-1]
345
+
346
+
347
+ def _growth_rows(groups: Sequence[RunGroup], times_of: Dict[str, List[List[Optional[float]]]]) -> List[Growth]:
348
+ rows: List[Growth] = []
349
+ for name, per_group in times_of.items():
350
+ for group, times in zip(groups, per_group):
351
+ values = growth_of(times)
352
+ if values is None:
353
+ continue
354
+ item = Growth(name, group.name, *values)
355
+ if item.growth_seconds > 0:
356
+ rows.append(item)
357
+ rows.sort(key=lambda r: (-r.growth_seconds, r.full_name))
358
+ return rows
359
+
360
+
361
+ def tests_growth(groups: Sequence[RunGroup]) -> List[Growth]:
362
+ names: Dict[str, List[List[Optional[float]]]] = {}
363
+ for run in all_runs(groups):
364
+ for name in run.snapshot.tests:
365
+ names.setdefault(name, [])
366
+ for name, per_group in names.items():
367
+ for group in groups:
368
+ per_group.append(
369
+ [t.elapsed_seconds if (t := run.snapshot.tests.get(name)) is not None else None for run in group.runs]
370
+ )
371
+ return _growth_rows(groups, names)
372
+
373
+
374
+ def suite_growth(groups: Sequence[RunGroup]) -> List[Growth]:
375
+ names: Dict[str, List[List[Optional[float]]]] = {}
376
+ for run in all_runs(groups):
377
+ for name in run.snapshot.suite_elapsed:
378
+ names.setdefault(name, [])
379
+ for name, per_group in names.items():
380
+ for group in groups:
381
+ per_group.append([run.snapshot.suite_elapsed.get(name) for run in group.runs])
382
+ return _growth_rows(groups, names)
383
+
384
+
385
+ # ---------------------------------------------------------------------------
386
+ # Messages of the runs
387
+ # ---------------------------------------------------------------------------
388
+
389
+
390
+ @dataclass
391
+ class MessageGroupInfo:
392
+ group: Optional[str]
393
+ first_run: Optional[int] = None
394
+ last_run: Optional[int] = None
395
+ new: bool = False
396
+ gone: bool = False
397
+
398
+
399
+ @dataclass
400
+ class MessageRow:
401
+ level: str
402
+ key: str
403
+ message: str
404
+ per_run: List[int]
405
+ per_group: List[MessageGroupInfo]
406
+
407
+
408
+ def level_counts(groups: Sequence[RunGroup]) -> Dict[str, List[int]]:
409
+ """Level -> number of messages per shown run, ERROR before WARN before the rest."""
410
+ runs = all_runs(groups)
411
+ counts: Dict[str, List[int]] = {}
412
+ for index, run in enumerate(runs):
413
+ for message in run.snapshot.messages:
414
+ counts.setdefault(message.level, [0] * len(runs))[index] += 1
415
+ return dict(sorted(counts.items(), key=lambda kv: (_LEVEL_RANK.get(kv[0], 99), kv[0])))
416
+
417
+
418
+ _LEVEL_RANK = {"ERROR": 0, "WARN": 1}
419
+
420
+
421
+ def message_rows(groups: Sequence[RunGroup]) -> List[MessageRow]:
422
+ """The run messages grouped by level and key: new ones first, then gone ones, then the most frequent."""
423
+ runs = all_runs(groups)
424
+ rows: Dict[Tuple[str, str], MessageRow] = {}
425
+ for index, run in enumerate(runs):
426
+ for message in run.snapshot.messages:
427
+ key = (message.level, message_key(message.text))
428
+ row = rows.get(key)
429
+ if row is None:
430
+ row = rows[key] = MessageRow(
431
+ message.level, key[1], message.text, [0] * len(runs), [MessageGroupInfo(g.name) for g in groups]
432
+ )
433
+ row.per_run[index] += 1
434
+
435
+ for row in rows.values():
436
+ offset = 0
437
+ for info, group in zip(row.per_group, groups):
438
+ seen = [run.number for i, run in enumerate(group.runs) if row.per_run[offset + i]]
439
+ offset += len(group.runs)
440
+ if not seen:
441
+ continue
442
+ info.first_run, info.last_run = seen[0], seen[-1]
443
+ last_number = group.runs[-1].number
444
+ info.new = info.first_run == last_number and len(group.runs) > 1
445
+ info.gone = info.last_run != last_number
446
+
447
+ def order(row: MessageRow) -> Tuple[int, int, int, str]:
448
+ new = any(i.new for i in row.per_group)
449
+ gone = any(i.gone for i in row.per_group)
450
+ return (0 if new else 1 if gone else 2, _LEVEL_RANK.get(row.level, 99), -sum(row.per_run), row.key)
451
+
452
+ return sorted(rows.values(), key=order)
453
+
454
+
455
+ # ---------------------------------------------------------------------------
456
+ # Environment of the runs
457
+ # ---------------------------------------------------------------------------
458
+
459
+ # `Robot 7.5 (Python 3.14.9 on linux)`, also `Rebot …` for files written by rebot
460
+ _GENERATOR_RE = re.compile(
461
+ r"^(?P<tool>\S+)\s+(?P<version>\S+)\s+\(Python\s+(?P<python>\S+)\s+on\s+(?P<platform>[^)]+)\)\s*$"
462
+ )
463
+
464
+
465
+ @dataclass
466
+ class Generator:
467
+ text: str
468
+ tool: str
469
+ version: Optional[str] = None
470
+ python: Optional[str] = None
471
+ platform: Optional[str] = None
472
+
473
+
474
+ def parse_generator(text: str) -> Generator:
475
+ """Split the generator a result file records; one that can't be split is the tool as it is."""
476
+ m = _GENERATOR_RE.match(text)
477
+ if m is None:
478
+ return Generator(text, text.strip())
479
+ return Generator(text, m["tool"], m["version"], m["python"], m["platform"].strip())
@@ -393,7 +393,7 @@ if _HAS_EXT:
393
393
  if src not in already_recorded:
394
394
  _make_embedded_artifact(src, "image", on_artifact)
395
395
  already_recorded.add(src)
396
- return f"_(embedded image — see artefacts: {alt or 'no alt text'})_"
396
+ return f"_(embedded image - see artefacts: {alt or 'no alt text'})_"
397
397
  if _is_external_url(src):
398
398
  return m.group(0)
399
399
  new = _make_external_artifact(src, "image", base_dir, on_artifact)
@@ -409,7 +409,7 @@ if _HAS_EXT:
409
409
  _make_embedded_artifact(href, "file", on_artifact, download_names.get(href))
410
410
  already_recorded.add(href)
411
411
  # html-to-markdown writes the URI as the text of a link with only spaces in it.
412
- return f"_(embedded {text if text and text != href else 'data'} — see artefacts)_"
412
+ return f"_(embedded {text if text and text != href else 'data'} - see artefacts)_"
413
413
  if _is_external_url(href):
414
414
  # The target stays, the images in the text may have been replaced.
415
415
  return f"[{text}]" + m.group(0)[len(m.group("text")) + 2 :]
@@ -561,7 +561,7 @@ else:
561
561
  if embedded:
562
562
  if not "".join(self._out[start + 1 :]).strip():
563
563
  self._emit("data")
564
- self._emit(" — see artefacts)_")
564
+ self._emit(" - see artefacts)_")
565
565
  else:
566
566
  self._emit("]")
567
567
  self._emit(f"({_md_url(href)})" if href else "()")
@@ -624,7 +624,7 @@ else:
624
624
  return
625
625
  if src.startswith("data:"):
626
626
  _make_embedded_artifact(src, "image", self._on_artifact)
627
- self._emit(f"_(embedded image — see artefacts: {alt or 'no alt text'})_")
627
+ self._emit(f"_(embedded image - see artefacts: {alt or 'no alt text'})_")
628
628
  return
629
629
  if _is_external_url(src):
630
630
  self._emit(f"![{alt}]({_md_url(src)})")
@@ -641,7 +641,7 @@ else:
641
641
  return
642
642
  if src.startswith("data:"):
643
643
  _make_embedded_artifact(src, "file", self._on_artifact)
644
- self._emit(f"_(embedded {kind} — see artefacts)_")
644
+ self._emit(f"_(embedded {kind} - see artefacts)_")
645
645
  return
646
646
  url = self._handle_href(src, kind="file")
647
647
  self._emit(f"[{kind}]({_md_url(url)})" if url else f"[{kind}]()")