#!/usr/bin/python

import sys
import math
import multiprocessing
import subprocess

if len(sys.argv) != 2:
    print("supply the path to the doctest executable as the first argument!")
    sys.exit(0)

# get the number of tests in the doctest executable
result = subprocess.Popen([sys.argv[1], "-dt-count"], stdout = subprocess.PIPE).communicate()[0]
num_tests = int(result.rsplit(' ', 1)[-1])

# calculate the ranges
cores = multiprocessing.cpu_count()
l = range(num_tests + 1)
n = int(math.ceil(float(len( l )) / cores))
data = [l[i : i + n] for i in range(1, len( l ), n)]
data = tuple([[x[0], x[-1]] for x in data])

# for 8 cores and 100 tests the ranges will look like this
# ([1, 13], [14, 26], [27, 39], [40, 52], [53, 65], [66, 78], [79, 91], [92, 100])

# the worker callback that runs the executable for the given range of tests
def worker((first, last)):
    subprocess.Popen([sys.argv[1], "-dt-first=%s -dt-last=%s" % (first, last)])

# run the tasks on a pool
if __name__ == '__main__':
    p = multiprocessing.Pool(cores)
    p.map(worker, data)
