Skip to content

Instantly share code, notes, and snippets.

@evilpie
Last active May 21, 2020 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evilpie/f3d0ae1d3461855bd080715f1f70d1a0 to your computer and use it in GitHub Desktop.
Save evilpie/f3d0ae1d3461855bd080715f1f70d1a0 to your computer and use it in GitHub Desktop.
An alternative runner for kraken
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import glob
import os
parser = argparse.ArgumentParser(description='Run kraken/sunspider.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'--shell',
dest='shell',
action='store',
type=argparse.FileType('r'),
required=True,
help='Path to JS shell',
)
parser.add_argument(
'--suite',
dest='suite',
action='store',
type=str,
default='kraken-1.1',
help='Test suite to run',
)
parser.add_argument(
'--args',
dest='shell_args',
action='store',
default='',
type=str,
help='JS shell arguments',
)
parser.add_argument('test', type=str, nargs='?', default='',
help='Runs tests containing this string')
args = parser.parse_args()
TEST_PREFIX_TEMPLATE = \
"""
var suiteName = "{suite}";
var tests = {tests};
var categories = {categories};
"""
DRIVER = 'resources/sunspider-standalone-driver.js'
# Find tests matching the 'test' argument (or any)
tests = []
categories = set()
with open('tests/{}/LIST'.format(args.suite), 'r') as f:
for line in f:
test = line.strip()
if args.test in test:
tests.append(test)
categories.add(test.split('-')[0])
# Write the *-results/sunspider-test-prefix.js file
test_prefix_path = \
'{}-results/sunspider-test-prefix.js'.format(args.suite)
test_prefix_contents = TEST_PREFIX_TEMPLATE.format(suite=args.suite,
tests=tests, categories=list(categories))
open(test_prefix_path, 'w').write(test_prefix_contents)
print('Tests: {}'.format(', '.join(tests)))
cmd = '{shell} {args} -f {prefix} -f {driver}'.format(shell=args.shell.name,
args=args.shell_args, prefix=test_prefix_path, driver=DRIVER)
print('Running: {}\n'.format(cmd))
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment