Remove a level of unnessary function call

This commit is contained in:
Shing Lyu 2016-11-16 17:16:03 +08:00
parent 9f0b685268
commit d9a7221b0c

View file

@ -9,7 +9,6 @@ import itertools
import json import json
import os import os
import subprocess import subprocess
import gecko_driver
from functools import partial from functools import partial
from statistics import median, StatisticsError from statistics import median, StatisticsError
@ -40,7 +39,6 @@ def execute_test(url, command, timeout):
return "" return ""
def get_servo_command(url):
def run_servo_test(url, timeout): def run_servo_test(url, timeout):
ua_script_path = "{}/user-agent-js".format(os.getcwd()) ua_script_path = "{}/user-agent-js".format(os.getcwd())
command = [ command = [
@ -57,16 +55,12 @@ def get_servo_command(url):
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print("Unexpected Fail:") print("Unexpected Fail:")
print(e) print(e)
print("You may want to re-run the test manually:\n{}" print("You may want to re-run the test manually:\n{}".format(
.format(' '.join(command))) ' '.join(command)
))
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
print("Test FAILED due to timeout: {}".format(url)) print("Test FAILED due to timeout: {}".format(url))
return parse_log(log, url) return parse_log(log, url)
return run_servo_test
def get_gecko_command(url):
return gecko_driver.run_gecko_test
def parse_log(log, testcase): def parse_log(log, testcase):
@ -255,15 +249,15 @@ def main():
" servo and gecko are supported.")) " servo and gecko are supported."))
args = parser.parse_args() args = parser.parse_args()
if args.engine == 'servo': if args.engine == 'servo':
command_factory = get_servo_command run_test = run_servo_test
elif args.engine == 'gecko': elif args.engine == 'gecko':
command_factory = get_gecko_command import gecko_driver # Load this only when we need gecko test
run_test = gecko_driver.run_gecko_test
try: try:
# Assume the server is up and running # Assume the server is up and running
testcases = load_manifest(args.tp5_manifest) testcases = load_manifest(args.tp5_manifest)
results = [] results = []
for testcase in testcases: for testcase in testcases:
run_test = command_factory(testcase)
for run in range(args.runs): for run in range(args.runs):
print("Running test {}/{} on {}".format(run + 1, print("Running test {}/{} on {}".format(run + 1,
args.runs, args.runs,