|
|
|
@ -33,7 +33,6 @@ import hashlib |
|
|
|
|
import multiprocessing |
|
|
|
|
import os |
|
|
|
|
import platform |
|
|
|
|
import random |
|
|
|
|
import signal |
|
|
|
|
import subprocess |
|
|
|
|
import sys |
|
|
|
@ -59,40 +58,6 @@ else: |
|
|
|
|
signal.signal(signal.SIGALRM, alarm_handler) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def shuffle_iteratable(it): |
|
|
|
|
"""Return an iterable that randomly walks it""" |
|
|
|
|
# take a random sampling from the passed in iterable |
|
|
|
|
# we take an element with probability 1/p and rapidly increase |
|
|
|
|
# p as we take elements - this gives us a somewhat random set of values before |
|
|
|
|
# we've seen all the values, but starts producing values without having to |
|
|
|
|
# compute ALL of them at once, allowing tests to start a little earlier |
|
|
|
|
LARGE_THRESHOLD = 1000 |
|
|
|
|
nextit = [] |
|
|
|
|
p = 1 |
|
|
|
|
for val in it: |
|
|
|
|
if random.randint(0, p) == 0: |
|
|
|
|
p = min(p*2, 100) |
|
|
|
|
yield val |
|
|
|
|
else: |
|
|
|
|
nextit.append(val) |
|
|
|
|
# if the input iterates over a large number of values (potentially |
|
|
|
|
# infinite, we'd be in the loop for a while (again, potentially forever). |
|
|
|
|
# We need to reset "nextit" every so often to, in the case of an infinite |
|
|
|
|
# iterator, avoid growing "nextit" without ever freeing it. |
|
|
|
|
if len(nextit) > LARGE_THRESHOLD: |
|
|
|
|
random.shuffle(nextit) |
|
|
|
|
for val in nextit: |
|
|
|
|
yield val |
|
|
|
|
nextit = [] |
|
|
|
|
p = 1 |
|
|
|
|
|
|
|
|
|
# after taking a random sampling, we shuffle the rest of the elements and |
|
|
|
|
# yield them |
|
|
|
|
random.shuffle(nextit) |
|
|
|
|
for val in nextit: |
|
|
|
|
yield val |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_SUCCESS = object() |
|
|
|
|
_FAILURE = object() |
|
|
|
|
_RUNNING = object() |
|
|
|
@ -358,11 +323,6 @@ def run(cmdlines, |
|
|
|
|
maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS, |
|
|
|
|
newline_on_success, travis, stop_on_failure, |
|
|
|
|
cache if cache is not None else NoCache()) |
|
|
|
|
# We can't sort an infinite sequence of runs. |
|
|
|
|
if not travis or infinite_runs: |
|
|
|
|
cmdlines = shuffle_iteratable(cmdlines) |
|
|
|
|
else: |
|
|
|
|
cmdlines = sorted(cmdlines, key=lambda x: x.shortname) |
|
|
|
|
for cmdline in cmdlines: |
|
|
|
|
if not js.start(cmdline): |
|
|
|
|
break |
|
|
|
|