Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: scripts/slave/recipe_modules/chromium_tests/steps.py

Issue 2439213002: Add step to process Render Test results. (Closed)
Patch Set: Added parens to nested_step_name Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import datetime 5 import datetime
6 import json 6 import json
7 import re 7 import re
8 import string 8 import string
9 9
10 10
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 def run_tests(self, api, suffix, json_results_file): 1477 def run_tests(self, api, suffix, json_results_file):
1478 """Runs the Android test suite and outputs the json results to a file. 1478 """Runs the Android test suite and outputs the json results to a file.
1479 1479
1480 Args: 1480 Args:
1481 api: Caller's API. 1481 api: Caller's API.
1482 suffix: Suffix added to the test name. 1482 suffix: Suffix added to the test name.
1483 json_results_file: File to output the test results. 1483 json_results_file: File to output the test results.
1484 """ 1484 """
1485 raise NotImplementedError() # pragma: no cover 1485 raise NotImplementedError() # pragma: no cover
1486 1486
1487 def run(self, api, suffix, test_filter=None): 1487 def run(self, api, suffix, test_filter=None):
jbudorick 2016/11/03 18:34:36 Implementing this in here will not work on the bot
mikecase (-- gone --) 2016/11/03 18:41:37 I don't think that is a problem. The logic to run
jbudorick 2016/11/07 21:58:56 I mean, it's ok for now, but if you want to use th
1488 assert api.chromium.c.TARGET_PLATFORM == 'android' 1488 assert api.chromium.c.TARGET_PLATFORM == 'android'
1489 json_results_file = api.test_utils.gtest_results(add_json_log=False)
1490 try:
1491 self.run_tests(api, suffix, json_results_file)
1492 finally:
1493 step_result = api.step.active_result
1494 self._test_runs[suffix] = {'valid': False}
1495 if (hasattr(step_result, 'test_utils') and
1496 hasattr(step_result.test_utils, 'gtest_results')):
1497 gtest_results = step_result.test_utils.gtest_results
1498 1489
1499 failures = gtest_results.failures 1490 nested_step_name = '%s%s' % (self._name, ' (%s)' % suffix if suffix else '')
1500 self._test_runs[suffix] = {'valid': True, 'failures': failures} 1491 with api.step.nest(nested_step_name) as nested_step:
1501 step_result.presentation.step_text += ( 1492 json_results_file = api.test_utils.gtest_results(add_json_log=False)
1502 api.test_utils.format_step_text([['failures:', failures]])) 1493 try:
1494 step_result = self.run_tests(api, suffix, json_results_file)
1495 except api.step.StepFailure as f:
1496 step_result = f.result
1497 raise
1498 finally:
1499 nested_step.presentation.status = step_result.presentation.status
1500 self._test_runs[suffix] = {'valid': False}
1501 if (hasattr(step_result, 'test_utils') and
1502 hasattr(step_result.test_utils, 'gtest_results')):
1503 gtest_results = step_result.test_utils.gtest_results
1503 1504
1504 api.test_results.upload( 1505 failures = gtest_results.failures
1505 api.json.input(gtest_results.raw), 1506 self._test_runs[suffix] = {'valid': True, 'failures': failures}
1506 test_type=self.name, 1507 nested_step.presentation.step_text += (
1507 chrome_revision=api.bot_update.last_returned_properties.get( 1508 api.test_utils.format_step_text([['failures:', failures]]))
mikecase (-- gone --) 2016/11/03 18:56:33 This is basically the only important line I added
jbudorick 2016/11/07 21:58:56 Ah, yeah, I see what you mean now.
1508 'got_revision_cp', 'x@{#0}'), 1509
1509 test_results_server='test-results.appspot.com') 1510 api.test_results.upload(
1511 api.json.input(gtest_results.raw),
1512 test_type=self.name,
1513 chrome_revision=api.bot_update.last_returned_properties.get(
1514 'got_revision_cp', 'x@{#0}'),
1515 test_results_server='test-results.appspot.com')
1510 1516
1511 def compile_targets(self, _): 1517 def compile_targets(self, _):
1512 return self._compile_targets 1518 return self._compile_targets
1513 1519
1514 def has_valid_results(self, api, suffix): 1520 def has_valid_results(self, api, suffix):
1515 if suffix not in self._test_runs: 1521 if suffix not in self._test_runs:
1516 return False # pragma: no cover 1522 return False # pragma: no cover
1517 return self._test_runs[suffix]['valid'] 1523 return self._test_runs[suffix]['valid']
1518 1524
1519 def failures(self, api, suffix): 1525 def failures(self, api, suffix):
1520 assert self.has_valid_results(api, suffix) 1526 assert self.has_valid_results(api, suffix)
1521 return self._test_runs[suffix]['failures'] 1527 return self._test_runs[suffix]['failures']
1522 1528
1523 1529
1524 class AndroidJunitTest(AndroidTest): 1530 class AndroidJunitTest(AndroidTest):
1525 def __init__(self, name): 1531 def __init__(self, name):
1526 super(AndroidJunitTest, self).__init__(name, compile_targets=[name], 1532 super(AndroidJunitTest, self).__init__(name, compile_targets=[name],
1527 isolate_file_path=None) 1533 isolate_file_path=None)
1528 1534
1529 @property 1535 @property
1530 def uses_local_devices(self): 1536 def uses_local_devices(self):
1531 return False 1537 return False
1532 1538
1533 #override 1539 #override
1534 def run_tests(self, api, suffix, json_results_file): 1540 def run_tests(self, api, suffix, json_results_file):
1535 api.chromium_android.run_java_unit_test_suite( 1541 return api.chromium_android.run_java_unit_test_suite(
1536 self.name, verbose=True, suffix=suffix, 1542 self.name, verbose=True, suffix=suffix,
1537 json_results_file=json_results_file, 1543 json_results_file=json_results_file,
1538 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False )) 1544 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False ))
1539 1545
1540 1546
1541 class AndroidInstrumentationTest(AndroidTest): 1547 class AndroidInstrumentationTest(AndroidTest):
1542 _DEFAULT_SUITES = { 1548 _DEFAULT_SUITES = {
1543 'AndroidWebViewTest': { 1549 'AndroidWebViewTest': {
1544 'compile_target': 'android_webview_test_apk', 1550 'compile_target': 'android_webview_test_apk',
1545 }, 1551 },
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 'mojo_test_apk': _DEFAULT_SUITES['MojoTest'], 1588 'mojo_test_apk': _DEFAULT_SUITES['MojoTest'],
1583 'remoting_test_apk': _DEFAULT_SUITES['ChromotingTest'], 1589 'remoting_test_apk': _DEFAULT_SUITES['ChromotingTest'],
1584 'system_webview_shell_layout_test_apk': 1590 'system_webview_shell_layout_test_apk':
1585 _DEFAULT_SUITES['SystemWebViewShellLayoutTest'], 1591 _DEFAULT_SUITES['SystemWebViewShellLayoutTest'],
1586 } 1592 }
1587 1593
1588 def __init__(self, name, compile_targets=None, apk_under_test=None, 1594 def __init__(self, name, compile_targets=None, apk_under_test=None,
1589 test_apk=None, isolate_file_path=None, timeout_scale=None, 1595 test_apk=None, isolate_file_path=None, timeout_scale=None,
1590 annotation=None, except_annotation=None, screenshot=False, 1596 annotation=None, except_annotation=None, screenshot=False,
1591 verbose=True, tool=None, additional_apks=None, 1597 verbose=True, tool=None, additional_apks=None,
1592 store_tombstones=False, result_details=False): 1598 store_tombstones=False, result_details=False,
1599 render_results_dir=None):
1593 suite_defaults = ( 1600 suite_defaults = (
1594 AndroidInstrumentationTest._DEFAULT_SUITES.get(name) 1601 AndroidInstrumentationTest._DEFAULT_SUITES.get(name)
1595 or AndroidInstrumentationTest._DEFAULT_SUITES_BY_TARGET.get(name) 1602 or AndroidInstrumentationTest._DEFAULT_SUITES_BY_TARGET.get(name)
1596 or {}) 1603 or {})
1597 if not compile_targets: 1604 if not compile_targets:
1598 compile_targets = [suite_defaults.get('compile_target', name)] 1605 compile_targets = [suite_defaults.get('compile_target', name)]
1599 compile_targets.extend( 1606 compile_targets.extend(
1600 suite_defaults.get('additional_compile_targets', [])) 1607 suite_defaults.get('additional_compile_targets', []))
1601 1608
1602 super(AndroidInstrumentationTest, self).__init__( 1609 super(AndroidInstrumentationTest, self).__init__(
1603 name, 1610 name,
1604 compile_targets, 1611 compile_targets,
1605 isolate_file_path or suite_defaults.get('isolate_file_path')) 1612 isolate_file_path or suite_defaults.get('isolate_file_path'))
1606 self._additional_apks = ( 1613 self._additional_apks = (
1607 additional_apks or suite_defaults.get('additional_apks')) 1614 additional_apks or suite_defaults.get('additional_apks'))
1608 self._annotation = annotation 1615 self._annotation = annotation
1609 self._apk_under_test = ( 1616 self._apk_under_test = (
1610 apk_under_test or suite_defaults.get('apk_under_test')) 1617 apk_under_test or suite_defaults.get('apk_under_test'))
1611 self._except_annotation = except_annotation 1618 self._except_annotation = except_annotation
1612 self._screenshot = screenshot 1619 self._screenshot = screenshot
1613 self._test_apk = test_apk or suite_defaults.get('test_apk') 1620 self._test_apk = test_apk or suite_defaults.get('test_apk')
1614 self._timeout_scale = timeout_scale 1621 self._timeout_scale = timeout_scale
1615 self._tool = tool 1622 self._tool = tool
1616 self._verbose = verbose 1623 self._verbose = verbose
1617 self._wrapper_script_suite_name = compile_targets[0] 1624 self._wrapper_script_suite_name = compile_targets[0]
1618 self._store_tombstones = store_tombstones 1625 self._store_tombstones = store_tombstones
1619 self._result_details = result_details 1626 self._result_details = result_details
1627 self._render_results_dir = render_results_dir
1620 1628
1621 @property 1629 @property
1622 def uses_local_devices(self): 1630 def uses_local_devices(self):
1623 return True 1631 return True
1624 1632
1625 #override 1633 #override
1626 def run_tests(self, api, suffix, json_results_file): 1634 def run_tests(self, api, suffix, json_results_file):
1627 api.chromium_android.run_instrumentation_suite( 1635 return api.chromium_android.run_instrumentation_suite(
1628 self.name, 1636 self.name,
1629 test_apk=api.chromium_android.apk_path(self._test_apk), 1637 test_apk=api.chromium_android.apk_path(self._test_apk),
1630 apk_under_test=api.chromium_android.apk_path(self._apk_under_test), 1638 apk_under_test=api.chromium_android.apk_path(self._apk_under_test),
1631 additional_apks=[ 1639 additional_apks=[
1632 api.chromium_android.apk_path(a) 1640 api.chromium_android.apk_path(a)
1633 for a in self._additional_apks or []], 1641 for a in self._additional_apks or []],
1634 suffix=suffix, 1642 suffix=suffix,
1635 isolate_file_path=self.isolate_file_path, 1643 isolate_file_path=self.isolate_file_path,
1636 annotation=self._annotation, except_annotation=self._except_annotation, 1644 annotation=self._annotation, except_annotation=self._except_annotation,
1637 screenshot=self._screenshot, verbose=self._verbose, tool=self._tool, 1645 screenshot=self._screenshot, verbose=self._verbose, tool=self._tool,
1638 json_results_file=json_results_file, 1646 json_results_file=json_results_file,
1639 timeout_scale=self._timeout_scale, 1647 timeout_scale=self._timeout_scale,
1640 result_details=self._result_details, 1648 result_details=self._result_details,
1641 store_tombstones=self._store_tombstones, 1649 store_tombstones=self._store_tombstones,
1642 wrapper_script_suite_name=self._wrapper_script_suite_name, 1650 wrapper_script_suite_name=self._wrapper_script_suite_name,
1651 render_results_dir=self._render_results_dir,
1643 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False )) 1652 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False ))
1644 1653
1645 1654
1646 class BlinkTest(Test): 1655 class BlinkTest(Test):
1647 # TODO(dpranke): This should be converted to a PythonBasedTest, although it 1656 # TODO(dpranke): This should be converted to a PythonBasedTest, although it
1648 # will need custom behavior because we archive the results as well. 1657 # will need custom behavior because we archive the results as well.
1649 def __init__(self, extra_args=None): 1658 def __init__(self, extra_args=None):
1650 super(BlinkTest, self).__init__() 1659 super(BlinkTest, self).__init__()
1651 self._extra_args = extra_args 1660 self._extra_args = extra_args
1652 1661
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 args=args) 1894 args=args)
1886 api.gsutil.upload( 1895 api.gsutil.upload(
1887 temp_output_dir.join( 1896 temp_output_dir.join(
1888 '%s-android-chrome.json' % timestamp_string), 1897 '%s-android-chrome.json' % timestamp_string),
1889 'chromium-annotated-tests', 'android') 1898 'chromium-annotated-tests', 'android')
1890 1899
1891 GOMA_TESTS = [ 1900 GOMA_TESTS = [
1892 GTestTest('base_unittests'), 1901 GTestTest('base_unittests'),
1893 GTestTest('content_unittests'), 1902 GTestTest('content_unittests'),
1894 ] 1903 ]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698