Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to try to run multiple WTR in parallel
#!/usr/bin/python3
import os
import sys
import argparse
from multiprocessing import Pool
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--processes', '-p', type=int, default=5, help='Maximum number of parallel processes')
parser.add_argument('--number', '-n', type=int, default=5, help='Number of tests to be run')
parser.add_argument('webkitdir', help='WebKit root directory')
parser.add_argument('test', help='Test case file')
return parser.parse_args()
def run_process(data):
i, command = data
print(f"Maestro: Starting job {i}")
os.system(command)
def main():
args = parse_args()
basepath = args.webkitdir
testcase = args.test
processes = args.processes
number = args.number
webkitbuild = os.path.join(basepath, 'WebKitBuild')
jhbuild_wrapper = os.path.join(basepath, 'Tools', 'jhbuild', 'jhbuild-wrapper')
wtr_exec = os.path.join(basepath, 'WebKitBuild', 'Debug', 'bin', 'WebKitTestRunner')
os.environ['TEST_RUNNER_INJECTED_BUNDLE_FILENAME'] = os.path.join(basepath, 'WebKitBuild', 'Debug', 'lib', 'libTestRunnerInjectedBundle.so')
command = f'{jhbuild_wrapper} --wpe run {wtr_exec} {testcase}'
pool = Pool(processes=processes)
pool.map(run_process, [(i, command) for i in range(number)])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment