• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / mozregression / 14446186470

14 Apr 2025 12:55PM CUT coverage: 35.284%. First build
14446186470

Pull #1971

github

web-flow
Merge 883f6a4c1 into 807564865
Pull Request #1971: build(deps): bump multidict from 6.0.5 to 6.4.3

995 of 2820 relevant lines covered (35.28%)

1.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.43
/mozregression/approx_persist.py
1
from __future__ import absolute_import
3✔
2

3
import re
3✔
4

5

6
class ApproxPersistChooser(object):
3✔
7
    """
8
    ApproxPersistChooser is able to pick a persistent file that is *near*
9
    the one we should download.
10

11
    For example, if you pass 7 for the *one_every* parameter, it will search
12
    for builds around the one we need in this way:
13

14
    0 if len(bisection range) is < 7
15
    1 if len(bisection range) is >= 7 and < 14
16
    2 if len(bisection range) is >= 14 and < 21
17
    ...
18

19
    So if the desired nightly build is 2015-07-10 and the bisection range is
20
    2015-07-05 - 2015-07-15, this will try to locate a persitent file from
21
    (in this order):
22

23
    2015-07-9
24
    2015-07-11
25
    """
26

27
    def __init__(self, one_every):
3✔
28
        self.one_every = abs(one_every)
×
29

30
    def _iter(self, build_range, build_info):
3✔
31
        """
32
        iterate over the possible file name regexes that can match
33
        an approx build, without the exact filename
34
        """
35
        around = len(build_range) // self.one_every
×
36
        index = build_range.index(build_info)
×
37

38
        def date_or_chset(next_index):
×
39
            # Return the date (for nightlies) or the changeset (for
40
            # taskcluster) associated with the FutureBuildInfo at the
41
            # given index.
42
            return build_info.persist_filename_for(
×
43
                # get_future can raise IndexError if we are out of bounds
44
                build_range.get_future(next_index).date_or_changeset()
45
            )
46

47
        first, last = 0, len(build_range) - 1
×
48
        for i in range(1, around + 1):
×
49
            try:
×
50
                next_index = index - i
×
51
                if next_index > first:
×
52
                    yield next_index, date_or_chset(next_index)
×
53
            except IndexError:
×
54
                pass
55
            try:
×
56
                next_index = index + i
×
57
                if next_index < last:
×
58
                    yield next_index, date_or_chset(next_index)
×
59
            except IndexError:
×
60
                pass
61

62
    def index(self, build_range, build_info, filenames):
3✔
63
        """
64
        Return the index in the build range that can be used to locate
65
        the approx build_info, or None if none can be found.
66
        """
67
        for index, fname in self._iter(build_range, build_info):
×
68
            reg = re.compile(fname)
×
69
            for other in filenames:
×
70
                if reg.match(other):
×
71
                    return index
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc