Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pavement.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from paver.easy import *
from paver.setuputils import setup
from multiprocess import Process
from multiprocessing import Semaphore
import platform
import json

MAX_PARALLELS = 2

setup(
name = "pytest-browserstack",
version = "0.1.0",
Expand All @@ -16,11 +19,12 @@
packages=['tests']
)

def run_py_test(config, task_id=0):
def run_py_test(config, task_id=0, sema=0):
if platform.system() == "Windows":
sh('cmd /C "set CONFIG_FILE=config/%s.json && set TASK_ID=%s && pytest -s tests/test_%s.py --driver Browserstack"' % (config, task_id, config))
else:
sh('CONFIG_FILE=config/%s.json TASK_ID=%s pytest -s tests/test_%s.py --driver Browserstack' % (config, task_id, config))
sema.release()

@task
@consume_nargs(1)
Expand All @@ -31,7 +35,11 @@ def run(args):
with open(config_file) as data_file:
CONFIG = json.load(data_file)
environments = CONFIG['environments']
sema = Semaphore(MAX_PARALLELS)
for i in range(len(environments)):
p = Process(target=run_py_test, args=(args[0], i))
sema.acquire()
p = Process(target=run_py_test, args=(args[0], i, sema))
jobs.append(p)
p.start()
for p in jobs:
p.join()