File: regression.py

package info (click to toggle)
python-invoke 1.4.1%2Bds-0.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,704 kB
  • sloc: python: 11,377; makefile: 18; sh: 12
file content (34 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Barebones regression-catching script that looks for ephemeral run() failures.

Intended to be run from top level of project via ``inv regression``. In an
ideal world this would be truly part of the integration test suite, but:

- something about the outer invoke or pytest environment seems to prevent such
  issues from appearing reliably (see eg issue #660)
- it can take quite a while to run, even compared to other integration tests.
"""


import sys

from invoke import task


@task
def check(c):
    count = 0
    failures = []
    for _ in range(0, 1000):
        count += 1
        try:
            # 'ls' chosen as an arbitrary, fast-enough-for-looping but
            # does-some-real-work example (where eg 'sleep' is less useful)
            response = c.run("ls", hide=True)
            if not response.ok:
                failures.append(response)
        except Exception as e:
            failures.append(e)
    if failures:
        print("run() FAILED {}/{} times!".format(len(failures), count))
        sys.exit(1)