Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 swarming_priority = swarming_spec.get('priority_adjustment') | 511 swarming_priority = swarming_spec.get('priority_adjustment') |
| 512 swarming_expiration = swarming_spec.get('expiration') | 512 swarming_expiration = swarming_spec.get('expiration') |
| 513 if use_swarming and swarming_dimension_sets: | 513 if use_swarming and swarming_dimension_sets: |
| 514 for dimensions in swarming_dimension_sets: | 514 for dimensions in swarming_dimension_sets: |
| 515 # TODO(stip): Swarmify instrumentation tests | 515 # TODO(stip): Swarmify instrumentation tests |
| 516 pass | 516 pass |
| 517 else: | 517 else: |
| 518 yield AndroidInstrumentationTest( | 518 yield AndroidInstrumentationTest( |
| 519 test_name, | 519 test_name, |
| 520 compile_targets=test.get('override_compile_targets'), | 520 compile_targets=test.get('override_compile_targets'), |
| 521 render_results_dir=test.get('render_results_dir'), | |
| 521 timeout_scale=test.get('timeout_scale'), | 522 timeout_scale=test.get('timeout_scale'), |
| 522 result_details=True, | 523 result_details=True, |
| 523 store_tombstones=True) | 524 store_tombstones=True) |
| 524 | 525 |
| 525 | 526 |
| 526 def generate_junit_test(api, chromium_tests_api, mastername, buildername, | 527 def generate_junit_test(api, chromium_tests_api, mastername, buildername, |
| 527 test_spec, bot_update_step, enable_swarming=False, | 528 test_spec, bot_update_step, enable_swarming=False, |
| 528 swarming_dimensions=None, | 529 swarming_dimensions=None, |
| 529 scripts_compile_targets=None): | 530 scripts_compile_targets=None): |
| 530 for test in test_spec.get(buildername, {}).get('junit_tests', []): | 531 for test in test_spec.get(buildername, {}).get('junit_tests', []): |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1494 | 1495 |
| 1495 Args: | 1496 Args: |
| 1496 api: Caller's API. | 1497 api: Caller's API. |
| 1497 suffix: Suffix added to the test name. | 1498 suffix: Suffix added to the test name. |
| 1498 json_results_file: File to output the test results. | 1499 json_results_file: File to output the test results. |
| 1499 """ | 1500 """ |
| 1500 raise NotImplementedError() # pragma: no cover | 1501 raise NotImplementedError() # pragma: no cover |
| 1501 | 1502 |
| 1502 def run(self, api, suffix, test_filter=None): | 1503 def run(self, api, suffix, test_filter=None): |
| 1503 assert api.chromium.c.TARGET_PLATFORM == 'android' | 1504 assert api.chromium.c.TARGET_PLATFORM == 'android' |
| 1504 json_results_file = api.test_utils.gtest_results(add_json_log=False) | |
| 1505 try: | |
| 1506 self.run_tests(api, suffix, json_results_file) | |
| 1507 finally: | |
| 1508 step_result = api.step.active_result | |
| 1509 self._test_runs[suffix] = {'valid': False} | |
| 1510 if (hasattr(step_result, 'test_utils') and | |
| 1511 hasattr(step_result.test_utils, 'gtest_results')): | |
| 1512 gtest_results = step_result.test_utils.gtest_results | |
| 1513 | 1505 |
| 1514 failures = gtest_results.failures | 1506 nested_step_name = '%s%s' % (self._name, ' (%s)' % suffix if suffix else '') |
| 1515 self._test_runs[suffix] = {'valid': True, 'failures': failures} | 1507 with api.step.nest(nested_step_name) as nested_step: |
|
ghost stip (do not use)
2016/12/08 20:16:02
cool, we may want to use this in other spots
| |
| 1516 step_result.presentation.step_text += ( | 1508 json_results_file = api.test_utils.gtest_results(add_json_log=False) |
| 1517 api.test_utils.format_step_text([['failures:', failures]])) | 1509 try: |
| 1510 step_result = self.run_tests(api, suffix, json_results_file) | |
| 1511 except api.step.StepFailure as f: | |
| 1512 step_result = f.result | |
| 1513 raise | |
| 1514 finally: | |
| 1515 nested_step.presentation.status = step_result.presentation.status | |
| 1516 self._test_runs[suffix] = {'valid': False} | |
| 1517 if (hasattr(step_result, 'test_utils') and | |
| 1518 hasattr(step_result.test_utils, 'gtest_results')): | |
| 1519 gtest_results = step_result.test_utils.gtest_results | |
| 1518 | 1520 |
| 1519 api.test_results.upload( | 1521 failures = gtest_results.failures |
| 1520 api.json.input(gtest_results.raw), | 1522 self._test_runs[suffix] = {'valid': True, 'failures': failures} |
| 1521 test_type=self.name, | 1523 nested_step.presentation.step_text += ( |
| 1522 chrome_revision=api.bot_update.last_returned_properties.get( | 1524 api.test_utils.format_step_text([['failures:', failures]])) |
| 1523 'got_revision_cp', 'x@{#0}'), | 1525 |
| 1524 test_results_server='test-results.appspot.com') | 1526 api.test_results.upload( |
| 1527 api.json.input(gtest_results.raw), | |
| 1528 test_type=self.name, | |
| 1529 chrome_revision=api.bot_update.last_returned_properties.get( | |
| 1530 'got_revision_cp', 'x@{#0}'), | |
| 1531 test_results_server='test-results.appspot.com') | |
| 1525 | 1532 |
| 1526 def compile_targets(self, _): | 1533 def compile_targets(self, _): |
| 1527 return self._compile_targets | 1534 return self._compile_targets |
| 1528 | 1535 |
| 1529 def has_valid_results(self, api, suffix): | 1536 def has_valid_results(self, api, suffix): |
| 1530 if suffix not in self._test_runs: | 1537 if suffix not in self._test_runs: |
| 1531 return False # pragma: no cover | 1538 return False # pragma: no cover |
| 1532 return self._test_runs[suffix]['valid'] | 1539 return self._test_runs[suffix]['valid'] |
| 1533 | 1540 |
| 1534 def failures(self, api, suffix): | 1541 def failures(self, api, suffix): |
| 1535 assert self.has_valid_results(api, suffix) | 1542 assert self.has_valid_results(api, suffix) |
| 1536 return self._test_runs[suffix]['failures'] | 1543 return self._test_runs[suffix]['failures'] |
| 1537 | 1544 |
| 1538 | 1545 |
| 1539 class AndroidJunitTest(AndroidTest): | 1546 class AndroidJunitTest(AndroidTest): |
| 1540 def __init__(self, name): | 1547 def __init__(self, name): |
| 1541 super(AndroidJunitTest, self).__init__(name, compile_targets=[name], | 1548 super(AndroidJunitTest, self).__init__(name, compile_targets=[name], |
| 1542 isolate_file_path=None) | 1549 isolate_file_path=None) |
| 1543 | 1550 |
| 1544 @property | 1551 @property |
| 1545 def uses_local_devices(self): | 1552 def uses_local_devices(self): |
| 1546 return False | 1553 return False |
| 1547 | 1554 |
| 1548 #override | 1555 #override |
| 1549 def run_tests(self, api, suffix, json_results_file): | 1556 def run_tests(self, api, suffix, json_results_file): |
| 1550 api.chromium_android.run_java_unit_test_suite( | 1557 return api.chromium_android.run_java_unit_test_suite( |
| 1551 self.name, verbose=True, suffix=suffix, | 1558 self.name, verbose=True, suffix=suffix, |
| 1552 json_results_file=json_results_file, | 1559 json_results_file=json_results_file, |
| 1553 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False )) | 1560 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False )) |
| 1554 | 1561 |
| 1555 | 1562 |
| 1556 class AndroidInstrumentationTest(AndroidTest): | 1563 class AndroidInstrumentationTest(AndroidTest): |
| 1557 _DEFAULT_SUITES = { | 1564 _DEFAULT_SUITES = { |
| 1558 'AndroidWebViewTest': { | 1565 'AndroidWebViewTest': { |
| 1559 'compile_target': 'android_webview_test_apk', | 1566 'compile_target': 'android_webview_test_apk', |
| 1560 }, | 1567 }, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1604 'remoting_test_apk': _DEFAULT_SUITES['ChromotingTest'], | 1611 'remoting_test_apk': _DEFAULT_SUITES['ChromotingTest'], |
| 1605 'system_webview_shell_layout_test_apk': | 1612 'system_webview_shell_layout_test_apk': |
| 1606 _DEFAULT_SUITES['SystemWebViewShellLayoutTest'], | 1613 _DEFAULT_SUITES['SystemWebViewShellLayoutTest'], |
| 1607 'webview_ui_test_app_test_apk': _DEFAULT_SUITES['WebViewUiTest'], | 1614 'webview_ui_test_app_test_apk': _DEFAULT_SUITES['WebViewUiTest'], |
| 1608 } | 1615 } |
| 1609 | 1616 |
| 1610 def __init__(self, name, compile_targets=None, apk_under_test=None, | 1617 def __init__(self, name, compile_targets=None, apk_under_test=None, |
| 1611 test_apk=None, isolate_file_path=None, timeout_scale=None, | 1618 test_apk=None, isolate_file_path=None, timeout_scale=None, |
| 1612 annotation=None, except_annotation=None, screenshot=False, | 1619 annotation=None, except_annotation=None, screenshot=False, |
| 1613 verbose=True, tool=None, additional_apks=None, | 1620 verbose=True, tool=None, additional_apks=None, |
| 1614 store_tombstones=False, result_details=False): | 1621 store_tombstones=False, result_details=False, |
| 1622 render_results_dir=None): | |
| 1615 suite_defaults = ( | 1623 suite_defaults = ( |
| 1616 AndroidInstrumentationTest._DEFAULT_SUITES.get(name) | 1624 AndroidInstrumentationTest._DEFAULT_SUITES.get(name) |
| 1617 or AndroidInstrumentationTest._DEFAULT_SUITES_BY_TARGET.get(name) | 1625 or AndroidInstrumentationTest._DEFAULT_SUITES_BY_TARGET.get(name) |
| 1618 or {}) | 1626 or {}) |
| 1619 if not compile_targets: | 1627 if not compile_targets: |
| 1620 compile_targets = [suite_defaults.get('compile_target', name)] | 1628 compile_targets = [suite_defaults.get('compile_target', name)] |
| 1621 compile_targets.extend( | 1629 compile_targets.extend( |
| 1622 suite_defaults.get('additional_compile_targets', [])) | 1630 suite_defaults.get('additional_compile_targets', [])) |
| 1623 | 1631 |
| 1624 super(AndroidInstrumentationTest, self).__init__( | 1632 super(AndroidInstrumentationTest, self).__init__( |
| 1625 name, | 1633 name, |
| 1626 compile_targets, | 1634 compile_targets, |
| 1627 isolate_file_path or suite_defaults.get('isolate_file_path')) | 1635 isolate_file_path or suite_defaults.get('isolate_file_path')) |
| 1628 self._additional_apks = ( | 1636 self._additional_apks = ( |
| 1629 additional_apks or suite_defaults.get('additional_apks')) | 1637 additional_apks or suite_defaults.get('additional_apks')) |
| 1630 self._annotation = annotation | 1638 self._annotation = annotation |
| 1631 self._apk_under_test = ( | 1639 self._apk_under_test = ( |
| 1632 apk_under_test or suite_defaults.get('apk_under_test')) | 1640 apk_under_test or suite_defaults.get('apk_under_test')) |
| 1633 self._except_annotation = except_annotation | 1641 self._except_annotation = except_annotation |
| 1634 self._screenshot = screenshot | 1642 self._screenshot = screenshot |
| 1635 self._test_apk = test_apk or suite_defaults.get('test_apk') | 1643 self._test_apk = test_apk or suite_defaults.get('test_apk') |
| 1636 self._timeout_scale = timeout_scale | 1644 self._timeout_scale = timeout_scale |
| 1637 self._tool = tool | 1645 self._tool = tool |
| 1638 self._verbose = verbose | 1646 self._verbose = verbose |
| 1639 self._wrapper_script_suite_name = compile_targets[0] | 1647 self._wrapper_script_suite_name = compile_targets[0] |
| 1640 self._store_tombstones = store_tombstones | 1648 self._store_tombstones = store_tombstones |
| 1641 self._result_details = result_details | 1649 self._result_details = result_details |
| 1650 self._render_results_dir = render_results_dir | |
| 1642 | 1651 |
| 1643 @property | 1652 @property |
| 1644 def uses_local_devices(self): | 1653 def uses_local_devices(self): |
| 1645 return True | 1654 return True |
| 1646 | 1655 |
| 1647 #override | 1656 #override |
| 1648 def run_tests(self, api, suffix, json_results_file): | 1657 def run_tests(self, api, suffix, json_results_file): |
| 1649 api.chromium_android.run_instrumentation_suite( | 1658 return api.chromium_android.run_instrumentation_suite( |
| 1650 self.name, | 1659 self.name, |
| 1651 test_apk=api.chromium_android.apk_path(self._test_apk), | 1660 test_apk=api.chromium_android.apk_path(self._test_apk), |
| 1652 apk_under_test=api.chromium_android.apk_path(self._apk_under_test), | 1661 apk_under_test=api.chromium_android.apk_path(self._apk_under_test), |
| 1653 additional_apks=[ | 1662 additional_apks=[ |
| 1654 api.chromium_android.apk_path(a) | 1663 api.chromium_android.apk_path(a) |
| 1655 for a in self._additional_apks or []], | 1664 for a in self._additional_apks or []], |
| 1656 suffix=suffix, | 1665 suffix=suffix, |
| 1657 isolate_file_path=self.isolate_file_path, | 1666 isolate_file_path=self.isolate_file_path, |
| 1658 annotation=self._annotation, except_annotation=self._except_annotation, | 1667 annotation=self._annotation, except_annotation=self._except_annotation, |
| 1659 screenshot=self._screenshot, verbose=self._verbose, tool=self._tool, | 1668 screenshot=self._screenshot, verbose=self._verbose, tool=self._tool, |
| 1660 json_results_file=json_results_file, | 1669 json_results_file=json_results_file, |
| 1661 timeout_scale=self._timeout_scale, | 1670 timeout_scale=self._timeout_scale, |
| 1662 result_details=self._result_details, | 1671 result_details=self._result_details, |
| 1663 store_tombstones=self._store_tombstones, | 1672 store_tombstones=self._store_tombstones, |
| 1664 wrapper_script_suite_name=self._wrapper_script_suite_name, | 1673 wrapper_script_suite_name=self._wrapper_script_suite_name, |
| 1674 render_results_dir=self._render_results_dir, | |
| 1665 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False )) | 1675 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False )) |
| 1666 | 1676 |
| 1667 | 1677 |
| 1668 class BlinkTest(Test): | 1678 class BlinkTest(Test): |
| 1669 # TODO(dpranke): This should be converted to a PythonBasedTest, although it | 1679 # TODO(dpranke): This should be converted to a PythonBasedTest, although it |
| 1670 # will need custom behavior because we archive the results as well. | 1680 # will need custom behavior because we archive the results as well. |
| 1671 def __init__(self, extra_args=None): | 1681 def __init__(self, extra_args=None): |
| 1672 super(BlinkTest, self).__init__() | 1682 super(BlinkTest, self).__init__() |
| 1673 self._extra_args = extra_args | 1683 self._extra_args = extra_args |
| 1674 | 1684 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1907 args=args) | 1917 args=args) |
| 1908 api.gsutil.upload( | 1918 api.gsutil.upload( |
| 1909 temp_output_dir.join( | 1919 temp_output_dir.join( |
| 1910 '%s-android-chrome.json' % timestamp_string), | 1920 '%s-android-chrome.json' % timestamp_string), |
| 1911 'chromium-annotated-tests', 'android') | 1921 'chromium-annotated-tests', 'android') |
| 1912 | 1922 |
| 1913 GOMA_TESTS = [ | 1923 GOMA_TESTS = [ |
| 1914 GTestTest('base_unittests'), | 1924 GTestTest('base_unittests'), |
| 1915 GTestTest('content_unittests'), | 1925 GTestTest('content_unittests'), |
| 1916 ] | 1926 ] |
| OLD | NEW |