| 1 |
""" |
| 2 |
Barebones regression-catching script that looks for ephemeral run() failures. |
| 3 |
|
| 4 |
Intended to be run from top level of project via ``inv regression``. In an |
| 5 |
ideal world this would be truly part of the integration test suite, but: |
| 6 |
|
| 7 |
- something about the outer invoke or pytest environment seems to prevent such |
| 8 |
issues from appearing reliably (see eg issue #660) |
| 9 |
- it can take quite a while to run, even compared to other integration tests. |
| 10 |
""" |
| 11 |
|
| 12 |
import sys |
| 13 |
|
| 14 |
from invoke import task |
| 15 |
|
| 16 |
|
| 17 |
@task |
| 18 |
def check(c) -> None: |
| 19 |
count = 0 |
| 20 |
failures = [] |
| 21 |
for _ in range(0, 1000): |
| 22 |
count += 1 |
| 23 |
try: |
| 24 |
# 'ls' chosen as an arbitrary, fast-enough-for-looping but |
| 25 |
# does-some-real-work example (where eg 'sleep' is less useful) |
| 26 |
response = c.run("ls", hide=True) |
| 27 |
if not response.ok: |
| 28 |
failures.append(response) |
| 29 |
except Exception as e: |
| 30 |
failures.append(e) |
| 31 |
if failures: |
| 32 |
print("run() FAILED {}/{} times!".format(len(failures), count)) |
| 33 |
sys.exit(1) |
| 34 |
else: |
| 35 |
print("No failures detected after {} runs, A-OK".format(count)) |