def test_file(filename): """Runs the Ts and Tp tests on the given config file and generates a report. Args: filename: the name of the file to run the tests on """ browser_config = [] tests = [] title = '' testdate = '' csv_dir = '' results_server = '' results_link = '' results = {} # Read in the profile info from the YAML config file config_file = open(filename, 'r') yaml_config = yaml.load(config_file) config_file.close() for item in yaml_config: if item == 'title': title = yaml_config[item] elif item == 'testdate': testdate = yaml_config[item] elif item == 'csv_dir': csv_dir = os.path.normpath(yaml_config[item]) if not os.path.exists(csv_dir): print "FAIL: path \"" + csv_dir + "\" does not exist" sys.exit(0) elif item == 'results_server': results_server = yaml_config[item] elif item == 'results_link' : results_link = yaml_config[item] if (results_link != results_server != ''): if not post_file.link_exists(results_server, results_link): sys.exit(0) browser_config = {'preferences' : yaml_config['preferences'], 'extensions' : yaml_config['extensions'], 'firefox' : yaml_config['firefox'], 'branch' : yaml_config['branch'], 'buildid' : yaml_config['buildid'], 'profile_path' : yaml_config['profile_path'], 'env' : yaml_config['env'], 'dirs' : yaml_config['dirs'], 'init_url' : yaml_config['init_url']} #normalize paths to work accross platforms browser_config['firefox'] = os.path.normpath(browser_config['firefox']) if browser_config['profile_path'] != {}: browser_config['profile_path'] = os.path.normpath(browser_config['profile_path']) for dir in browser_config['dirs']: browser_config['dirs'][dir] = os.path.normpath(browser_config['dirs'][dir]) tests = yaml_config['tests'] config_file.close() if (testdate != ''): date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT'))) else: date = int(time.time()) #TODO get this into own file utils.debug("using testdate: %d" % date) utils.debug("actual date: %d" % int(time.time())) utils.stamped_msg(title, "Started") for test in tests: utils.stamped_msg("Running test " + test, "Started") try: browser_dump, counter_dump = ttest.runTest(browser_config, tests[test]) except talosError, e: utils.stamped_msg("Failed " + test, "Stopped") print 'FAIL: Busted: ' + test print 'FAIL: ' + e.msg sys.exit(0) utils.debug("Received test results: " + " ".join(browser_dump)) results[test] = [browser_dump, counter_dump] utils.stamped_msg("Completed test " + test, "Stopped")
def test_file(filename): """Runs the talos tests on the given config file and generates a report. Args: filename: the name of the file to run the tests on """ browser_config = [] tests = [] title = '' testdate = '' csv_dir = '' results_server = '' results_link = '' results = {} # Read in the profile info from the YAML config file config_file = open(filename, 'r') yaml_config = yaml.load(config_file) config_file.close() for item in yaml_config: if item == 'title': title = yaml_config[item] elif item == 'testdate': testdate = yaml_config[item] elif item == 'csv_dir': csv_dir = os.path.normpath(yaml_config[item]) if not os.path.exists(csv_dir): print "FAIL: path \"" + csv_dir + "\" does not exist" sys.exit(0) elif item == 'results_server': results_server = yaml_config[item] elif item == 'results_link' : results_link = yaml_config[item] if (results_link != results_server != ''): if not post_file.link_exists(results_server, results_link): sys.exit(0) browser_config = {'preferences' : yaml_config['preferences'], 'extensions' : yaml_config['extensions'], 'browser_path' : yaml_config['browser_path'], 'browser_log' : yaml_config['browser_log'], 'symbols_path' : yaml_config.get('symbols_path', None), 'browser_wait' : yaml_config['browser_wait'], 'process' : yaml_config['process'], 'extra_args' : yaml_config['extra_args'], 'branch' : yaml_config['branch'], 'buildid' : yaml_config['buildid'], 'env' : yaml_config['env'], 'dirs' : yaml_config['dirs'], 'init_url' : yaml_config['init_url']} if 'branch_name' in yaml_config: browser_config['branch_name'] = yaml_config['branch_name'] if 'test_name_extension' in yaml_config: browser_config['test_name_extension'] = yaml_config['test_name_extension'] else: browser_config['test_name_extension'] = '' #normalize paths to work accross platforms browser_config['browser_path'] = os.path.normpath(browser_config['browser_path']) for dir in browser_config['dirs']: browser_config['dirs'][dir] = os.path.normpath(browser_config['dirs'][dir]) tests = yaml_config['tests'] config_file.close() if (testdate != ''): date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT'))) else: date = int(time.time()) #TODO get this into own file utils.debug("using testdate: %d" % date) utils.debug("actual date: %d" % int(time.time())) print 'RETURN:s: %s' % title #pull buildid & sourcestamp from browser browser_config = browserInfo(browser_config) if ffprocess.checkAllProcesses(browser_config['process']): print "FAIL: all firefox processes must be closed before tests can be run" sys.exit(0) utils.startTimer() utils.stamped_msg(title, "Started") for test in tests: testname = test['name'] utils.stamped_msg("Running test " + testname, "Started") try: browser_dump, counter_dump, print_format = ttest.runTest(browser_config, test) utils.debug("Received test results: " + " ".join(browser_dump)) results[testname] = [browser_dump, counter_dump, print_format] # If we're doing CSV, write this test immediately (bug 419367) if csv_dir != '': send_to_csv(csv_dir, {testname : results[testname]}) except talosError, e: utils.stamped_msg("Failed " + testname, "Stopped") print 'FAIL: Busted: ' + testname print 'FAIL: ' + e.msg.replace('\n','\nRETURN:') utils.stamped_msg("Completed test " + testname, "Stopped")
def test_file(filename): """Runs the Ts and Tp tests on the given config file and generates a report. Args: filename: the name of the file to run the tests on """ browser_config = [] tests = [] title = '' testdate = '' csv_dir = '' results_server = '' results_link = '' results = {} # Read in the profile info from the YAML config file config_file = open(filename, 'r') yaml_config = yaml.load(config_file) config_file.close() for item in yaml_config: if item == 'title': title = yaml_config[item] elif item == 'testdate': testdate = yaml_config[item] elif item == 'csv_dir': csv_dir = os.path.normpath(yaml_config[item]) if not os.path.exists(csv_dir): print "FAIL: path \"" + csv_dir + "\" does not exist" sys.exit(0) elif item == 'results_server': results_server = yaml_config[item] elif item == 'results_link': results_link = yaml_config[item] if (results_link != results_server != ''): if not post_file.link_exists(results_server, results_link): sys.exit(0) browser_config = { 'preferences': yaml_config['preferences'], 'extensions': yaml_config['extensions'], 'firefox': yaml_config['firefox'], 'branch': yaml_config['branch'], 'buildid': yaml_config['buildid'], 'profile_path': yaml_config['profile_path'], 'env': yaml_config['env'], 'dirs': yaml_config['dirs'], 'init_url': yaml_config['init_url'] } #normalize paths to work accross platforms browser_config['firefox'] = os.path.normpath(browser_config['firefox']) if browser_config['profile_path'] != {}: browser_config['profile_path'] = os.path.normpath( browser_config['profile_path']) for dir in browser_config['dirs']: browser_config['dirs'][dir] = os.path.normpath( browser_config['dirs'][dir]) tests = yaml_config['tests'] config_file.close() if (testdate != ''): date = int( time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT'))) else: date = int(time.time()) #TODO get this into own file utils.debug("using testdate: %d" % date) utils.debug("actual date: %d" % int(time.time())) utils.stamped_msg(title, "Started") for test in tests: utils.stamped_msg("Running test " + test, "Started") try: browser_dump, counter_dump = ttest.runTest(browser_config, tests[test]) except talosError, e: utils.stamped_msg("Failed " + test, "Stopped") print 'FAIL: Busted: ' + test print 'FAIL: ' + e.msg sys.exit(0) utils.debug("Received test results: " + " ".join(browser_dump)) results[test] = [browser_dump, counter_dump] utils.stamped_msg("Completed test " + test, "Stopped")
def test_file(filename): """Runs the talos tests on the given config file and generates a report. Args: filename: the name of the file to run the tests on """ browser_config = [] tests = [] title = '' testdate = '' csv_dir = '' results_server = '' results_link = '' old_results_server = '' old_results_link = '' results = {} # Read in the profile info from the YAML config file config_file = open(filename, 'r') yaml_config = yaml.load(config_file) config_file.close() for item in yaml_config: if item == 'title': title = yaml_config[item] elif item == 'testdate': testdate = yaml_config[item] elif item == 'csv_dir': csv_dir = os.path.normpath(yaml_config[item]) if not os.path.exists(csv_dir): print "FAIL: path \"" + csv_dir + "\" does not exist" sys.exit(0) elif item == 'results_server': results_server = yaml_config[item] elif item == 'results_link': results_link = yaml_config[item] elif item == 'old_results_server': old_results_server = yaml_config[item] elif item == 'old_results_link': old_results_link = yaml_config[item] if (results_link != results_server != ''): if not post_file.link_exists(results_server, results_link): sys.exit(0) if (old_results_link != old_results_server != ''): if not post_file.link_exists(old_results_server, old_results_link): sys.exit(0) browser_config = { 'preferences': yaml_config['preferences'], 'extensions': yaml_config['extensions'], 'browser_path': yaml_config['browser_path'], 'browser_log': yaml_config['browser_log'], 'symbols_path': yaml_config.get('symbols_path', None), 'browser_wait': yaml_config['browser_wait'], 'process': yaml_config['process'], 'extra_args': yaml_config['extra_args'], 'branch': yaml_config['branch'], 'buildid': yaml_config['buildid'], 'profile_path': yaml_config['profile_path'], 'env': yaml_config['env'], 'dirs': yaml_config['dirs'], 'init_url': yaml_config['init_url'] } if 'branch_name' in yaml_config: browser_config['branch_name'] = yaml_config['branch_name'] if 'test_name_extension' in yaml_config: browser_config['test_name_extension'] = yaml_config[ 'test_name_extension'] else: browser_config['test_name_extension'] = '' #normalize paths to work accross platforms browser_config['browser_path'] = os.path.normpath( browser_config['browser_path']) if browser_config['profile_path'] != {}: browser_config['profile_path'] = os.path.normpath( browser_config['profile_path']) for dir in browser_config['dirs']: browser_config['dirs'][dir] = os.path.normpath( browser_config['dirs'][dir]) tests = yaml_config['tests'] config_file.close() if (testdate != ''): date = int( time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT'))) else: date = int(time.time()) #TODO get this into own file utils.debug("using testdate: %d" % date) utils.debug("actual date: %d" % int(time.time())) print 'RETURN:s: %s' % title #pull buildid & sourcestamp from browser browser_config = browserInfo(browser_config) utils.startTimer() utils.stamped_msg(title, "Started") for test in tests: testname = test['name'] utils.stamped_msg("Running test " + testname, "Started") try: browser_dump, counter_dump = ttest.runTest(browser_config, test) utils.debug("Received test results: " + " ".join(browser_dump)) results[testname] = [browser_dump, counter_dump] # If we're doing CSV, write this test immediately (bug 419367) if csv_dir != '': send_to_csv(csv_dir, {testname: results[testname]}) except talosError, e: utils.stamped_msg("Failed " + testname, "Stopped") print 'FAIL: Busted: ' + testname print 'FAIL: ' + e.msg utils.stamped_msg("Completed test " + testname, "Stopped")