• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from __future__ import annotations
6
7from typing import TYPE_CHECKING, Iterable
8
9from crossbench.runner.groups.base import RunGroup
10
11if TYPE_CHECKING:
12  from crossbench import exception
13  from crossbench.browsers.browser import Browser
14  from crossbench.probes.probe import Probe
15  from crossbench.probes.results import ProbeResult
16  from crossbench.runner.groups.repetitions import RepetitionsRunGroup
17  from crossbench.runner.groups.stories import StoriesRunGroup
18  from crossbench.runner.run import Run
19
20
21class BrowsersRunGroup(RunGroup):
22
23  def __init__(self, story_groups: Iterable[StoriesRunGroup],
24               throw: bool) -> None:
25    super().__init__(throw)
26    self._story_groups = tuple(story_groups)
27    if not story_groups:
28      raise ValueError("No story groups provided")
29    self._set_path(self._story_groups[0].path.parents[1])
30
31  @property
32  def story_groups(self) -> Iterable[StoriesRunGroup]:
33    return self._story_groups
34
35  @property
36  def browsers(self) -> Iterable[Browser]:
37    for story_group in self._story_groups:
38      yield story_group.browser
39
40  @property
41  def repetitions_groups(self) -> Iterable[RepetitionsRunGroup]:
42    for story_group in self._story_groups:
43      yield from story_group.repetitions_groups
44
45  @property
46  def runs(self) -> Iterable[Run]:
47    for group in self._story_groups:
48      yield from group.runs
49
50  @property
51  def info_stack(self) -> exception.TInfoStack:
52    return ("Merging results from multiple browsers",)
53
54  def _merge_probe_results(self, probe: Probe) -> ProbeResult:
55    return probe.merge_browsers(self)
56