Created
June 30, 2015 09:15
-
-
Save s1ider/f13c2f163282dbec7a61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
from subprocess import call, Popen, PIPE | |
from glob import glob | |
from datetime import datetime | |
import logging | |
import argparse | |
import json | |
from functools import partial | |
logging.basicConfig(level=logging.INFO, | |
format="[%(levelname)-8s %(asctime)s] %(message)s") | |
logger = logging.getLogger(__name__) | |
def parse_arguments(): | |
parser = argparse.ArgumentParser('Run Ikarus in parallel mode') | |
parser.add_argument('-c', type=int, help='number of concurrent runs ' | |
'(default = 5)', default=5) | |
parser.add_argument('--verbose', '-v', action='store_true', help='verbose ' | |
'output') | |
parser.add_argument('--tags', '-t', help='specify behave tags to run') | |
args = parser.parse_args() | |
return args | |
def _run_feature(feature, tags=None): | |
logger.debug("Processing feature: {}".format(feature)) | |
params = "--tags={}".format(tags) | |
cmd = "behave -f plain {0} -i {1}".format(params, feature) | |
r = call(cmd, shell=True) | |
status = 'ok' if r == 0 else 'failed' | |
return feature, status | |
def main(): | |
args = parse_arguments() | |
pool = Pool(args.c) | |
if args.tags: | |
p = Popen('behave -d -f json --no-summary -t {}'.format(args.tags), | |
stdout=PIPE, shell=True) | |
out, err = p.communicate() | |
j = json.loads(out) | |
features = [e['location'].replace(r'features/', ''). | |
replace(':1', '') for e in j] | |
else: | |
feature_files = glob('features/*.feature') + glob('features/**/*.feature') | |
features = [x.replace('features/', '') for x in feature_files] | |
run_feature = partial(_run_feature, tags=args.tags) | |
logger.info("Found {} features".format(len(features))) | |
logger.debug(features) | |
# features = [f for f in features if 'aft' not in f] | |
for feature, status in pool.map(run_feature, features): | |
print "{0:50}: {1}".format(feature, status) | |
if __name__ == '__main__': | |
main() |
👍 for some manual/docs.
Hi, Can someone show of how to run this runner file with examples??
any answer on this matter?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks!/
Ok, and how about some manual?
It would be great to see commands to run tests, with params and other staff.