| 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 from recipe_engine.types import freeze | 10 from recipe_engine.types import freeze |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 args = get_args_for_test(api, chromium_tests_api, test, | 596 args = get_args_for_test(api, chromium_tests_api, test, |
| 597 bot_update_step) | 597 bot_update_step) |
| 598 if use_swarming and swarming_dimension_sets: | 598 if use_swarming and swarming_dimension_sets: |
| 599 for dimensions in swarming_dimension_sets: | 599 for dimensions in swarming_dimension_sets: |
| 600 # TODO(stip): Swarmify instrumentation tests | 600 # TODO(stip): Swarmify instrumentation tests |
| 601 pass | 601 pass |
| 602 else: | 602 else: |
| 603 yield AndroidInstrumentationTest( | 603 yield AndroidInstrumentationTest( |
| 604 test_name, | 604 test_name, |
| 605 compile_targets=test.get('override_compile_targets'), | 605 compile_targets=test.get('override_compile_targets'), |
| 606 render_results_dir=test.get('render_results_dir'), |
| 606 timeout_scale=test.get('timeout_scale'), | 607 timeout_scale=test.get('timeout_scale'), |
| 607 result_details=True, | 608 result_details=True, |
| 608 store_tombstones=True, | 609 store_tombstones=True, |
| 609 args=args, | 610 args=args, |
| 610 waterfall_mastername=mastername, waterfall_buildername=buildername) | 611 waterfall_mastername=mastername, waterfall_buildername=buildername) |
| 611 | 612 |
| 612 | 613 |
| 613 def generate_junit_test(api, chromium_tests_api, mastername, buildername, | 614 def generate_junit_test(api, chromium_tests_api, mastername, buildername, |
| 614 test_spec, bot_update_step, enable_swarming=False, | 615 test_spec, bot_update_step, enable_swarming=False, |
| 615 swarming_dimensions=None, | 616 swarming_dimensions=None, |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 | 1683 |
| 1683 Args: | 1684 Args: |
| 1684 api: Caller's API. | 1685 api: Caller's API. |
| 1685 suffix: Suffix added to the test name. | 1686 suffix: Suffix added to the test name. |
| 1686 json_results_file: File to output the test results. | 1687 json_results_file: File to output the test results. |
| 1687 """ | 1688 """ |
| 1688 raise NotImplementedError() # pragma: no cover | 1689 raise NotImplementedError() # pragma: no cover |
| 1689 | 1690 |
| 1690 def run(self, api, suffix): | 1691 def run(self, api, suffix): |
| 1691 assert api.chromium.c.TARGET_PLATFORM == 'android' | 1692 assert api.chromium.c.TARGET_PLATFORM == 'android' |
| 1692 json_results_file = api.test_utils.gtest_results(add_json_log=False) | |
| 1693 try: | |
| 1694 self.run_tests(api, suffix, json_results_file) | |
| 1695 finally: | |
| 1696 step_result = api.step.active_result | |
| 1697 self._test_runs[suffix] = {'valid': False} | |
| 1698 if (hasattr(step_result, 'test_utils') and | |
| 1699 hasattr(step_result.test_utils, 'gtest_results')): | |
| 1700 gtest_results = step_result.test_utils.gtest_results | |
| 1701 | 1693 |
| 1702 failures = gtest_results.failures | 1694 nested_step_name = '%s%s' % (self._name, ' (%s)' % suffix if suffix else '') |
| 1703 self._test_runs[suffix] = {'valid': True, 'failures': failures} | 1695 with api.step.nest(nested_step_name) as nested_step: |
| 1704 step_result.presentation.step_text += ( | 1696 json_results_file = api.test_utils.gtest_results(add_json_log=False) |
| 1705 api.test_utils.format_step_text([['failures:', failures]])) | 1697 try: |
| 1698 step_result = self.run_tests(api, suffix, json_results_file) |
| 1699 except api.step.StepFailure as f: |
| 1700 step_result = f.result |
| 1701 raise |
| 1702 finally: |
| 1703 nested_step.presentation.status = step_result.presentation.status |
| 1704 self._test_runs[suffix] = {'valid': False} |
| 1705 if (hasattr(step_result, 'test_utils') and |
| 1706 hasattr(step_result.test_utils, 'gtest_results')): |
| 1707 gtest_results = step_result.test_utils.gtest_results |
| 1706 | 1708 |
| 1707 api.test_results.upload( | 1709 failures = gtest_results.failures |
| 1708 api.json.input(gtest_results.raw), | 1710 self._test_runs[suffix] = {'valid': True, 'failures': failures} |
| 1709 test_type=self.name, | 1711 nested_step.presentation.step_text += ( |
| 1710 chrome_revision=api.bot_update.last_returned_properties.get( | 1712 api.test_utils.format_step_text([['failures:', failures]])) |
| 1711 'got_revision_cp', 'x@{#0}'), | 1713 |
| 1712 test_results_server='test-results.appspot.com') | 1714 api.test_results.upload( |
| 1715 api.json.input(gtest_results.raw), |
| 1716 test_type=self.name, |
| 1717 chrome_revision=api.bot_update.last_returned_properties.get( |
| 1718 'got_revision_cp', 'x@{#0}'), |
| 1719 test_results_server='test-results.appspot.com') |
| 1713 | 1720 |
| 1714 def compile_targets(self, _): | 1721 def compile_targets(self, _): |
| 1715 return self._compile_targets | 1722 return self._compile_targets |
| 1716 | 1723 |
| 1717 def has_valid_results(self, api, suffix): | 1724 def has_valid_results(self, api, suffix): |
| 1718 if suffix not in self._test_runs: | 1725 if suffix not in self._test_runs: |
| 1719 return False # pragma: no cover | 1726 return False # pragma: no cover |
| 1720 return self._test_runs[suffix]['valid'] | 1727 return self._test_runs[suffix]['valid'] |
| 1721 | 1728 |
| 1722 def failures(self, api, suffix): | 1729 def failures(self, api, suffix): |
| 1723 assert self.has_valid_results(api, suffix) | 1730 assert self.has_valid_results(api, suffix) |
| 1724 return self._test_runs[suffix]['failures'] | 1731 return self._test_runs[suffix]['failures'] |
| 1725 | 1732 |
| 1726 | 1733 |
| 1727 class AndroidJunitTest(AndroidTest): | 1734 class AndroidJunitTest(AndroidTest): |
| 1728 def __init__( | 1735 def __init__( |
| 1729 self, name, waterfall_mastername=None, waterfall_buildername=None): | 1736 self, name, waterfall_mastername=None, waterfall_buildername=None): |
| 1730 super(AndroidJunitTest, self).__init__( | 1737 super(AndroidJunitTest, self).__init__( |
| 1731 name, compile_targets=[name], waterfall_mastername=None, | 1738 name, compile_targets=[name], waterfall_mastername=None, |
| 1732 waterfall_buildername=None) | 1739 waterfall_buildername=None) |
| 1733 | 1740 |
| 1734 @property | 1741 @property |
| 1735 def uses_local_devices(self): | 1742 def uses_local_devices(self): |
| 1736 return False | 1743 return False |
| 1737 | 1744 |
| 1738 #override | 1745 #override |
| 1739 def run_tests(self, api, suffix, json_results_file): | 1746 def run_tests(self, api, suffix, json_results_file): |
| 1740 api.chromium_android.run_java_unit_test_suite( | 1747 return api.chromium_android.run_java_unit_test_suite( |
| 1741 self.name, verbose=True, suffix=suffix, | 1748 self.name, verbose=True, suffix=suffix, |
| 1742 json_results_file=json_results_file, | 1749 json_results_file=json_results_file, |
| 1743 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False
)) | 1750 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False
)) |
| 1744 | 1751 |
| 1745 | 1752 |
| 1746 class AndroidInstrumentationTest(AndroidTest): | 1753 class AndroidInstrumentationTest(AndroidTest): |
| 1747 _DEFAULT_SUITES = { | 1754 _DEFAULT_SUITES = { |
| 1748 'AndroidWebViewTest': { | 1755 'AndroidWebViewTest': { |
| 1749 'compile_target': 'android_webview_test_apk', | 1756 'compile_target': 'android_webview_test_apk', |
| 1750 }, | 1757 }, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 'remoting_test_apk': _DEFAULT_SUITES['ChromotingTest'], | 1804 'remoting_test_apk': _DEFAULT_SUITES['ChromotingTest'], |
| 1798 'system_webview_shell_layout_test_apk': | 1805 'system_webview_shell_layout_test_apk': |
| 1799 _DEFAULT_SUITES['SystemWebViewShellLayoutTest'], | 1806 _DEFAULT_SUITES['SystemWebViewShellLayoutTest'], |
| 1800 'webview_ui_test_app_test_apk': _DEFAULT_SUITES['WebViewUiTest'], | 1807 'webview_ui_test_app_test_apk': _DEFAULT_SUITES['WebViewUiTest'], |
| 1801 } | 1808 } |
| 1802 | 1809 |
| 1803 def __init__(self, name, compile_targets=None, apk_under_test=None, | 1810 def __init__(self, name, compile_targets=None, apk_under_test=None, |
| 1804 test_apk=None, timeout_scale=None, annotation=None, | 1811 test_apk=None, timeout_scale=None, annotation=None, |
| 1805 except_annotation=None, screenshot=False, verbose=True, | 1812 except_annotation=None, screenshot=False, verbose=True, |
| 1806 tool=None, additional_apks=None, store_tombstones=False, | 1813 tool=None, additional_apks=None, store_tombstones=False, |
| 1807 result_details=False, args=None, waterfall_mastername=None, | 1814 result_details=False, render_results_dir=None, |
| 1815 args=None, waterfall_mastername=None, |
| 1808 waterfall_buildername=None): | 1816 waterfall_buildername=None): |
| 1809 suite_defaults = ( | 1817 suite_defaults = ( |
| 1810 AndroidInstrumentationTest._DEFAULT_SUITES.get(name) | 1818 AndroidInstrumentationTest._DEFAULT_SUITES.get(name) |
| 1811 or AndroidInstrumentationTest._DEFAULT_SUITES_BY_TARGET.get(name) | 1819 or AndroidInstrumentationTest._DEFAULT_SUITES_BY_TARGET.get(name) |
| 1812 or {}) | 1820 or {}) |
| 1813 if not compile_targets: | 1821 if not compile_targets: |
| 1814 compile_targets = [suite_defaults.get('compile_target', name)] | 1822 compile_targets = [suite_defaults.get('compile_target', name)] |
| 1815 compile_targets.extend( | 1823 compile_targets.extend( |
| 1816 suite_defaults.get('additional_compile_targets', [])) | 1824 suite_defaults.get('additional_compile_targets', [])) |
| 1817 | 1825 |
| 1818 super(AndroidInstrumentationTest, self).__init__( | 1826 super(AndroidInstrumentationTest, self).__init__( |
| 1819 name, | 1827 name, |
| 1820 compile_targets, | 1828 compile_targets, |
| 1821 waterfall_mastername=waterfall_mastername, | 1829 waterfall_mastername=waterfall_mastername, |
| 1822 waterfall_buildername=waterfall_buildername) | 1830 waterfall_buildername=waterfall_buildername) |
| 1823 self._additional_apks = ( | 1831 self._additional_apks = ( |
| 1824 additional_apks or suite_defaults.get('additional_apks')) | 1832 additional_apks or suite_defaults.get('additional_apks')) |
| 1825 self._annotation = annotation | 1833 self._annotation = annotation |
| 1826 self._apk_under_test = ( | 1834 self._apk_under_test = ( |
| 1827 apk_under_test or suite_defaults.get('apk_under_test')) | 1835 apk_under_test or suite_defaults.get('apk_under_test')) |
| 1828 self._except_annotation = except_annotation | 1836 self._except_annotation = except_annotation |
| 1829 self._screenshot = screenshot | 1837 self._screenshot = screenshot |
| 1830 self._test_apk = test_apk or suite_defaults.get('test_apk') | 1838 self._test_apk = test_apk or suite_defaults.get('test_apk') |
| 1831 self._timeout_scale = timeout_scale | 1839 self._timeout_scale = timeout_scale |
| 1832 self._tool = tool | 1840 self._tool = tool |
| 1833 self._verbose = verbose | 1841 self._verbose = verbose |
| 1834 self._wrapper_script_suite_name = compile_targets[0] | 1842 self._wrapper_script_suite_name = compile_targets[0] |
| 1835 self._store_tombstones = store_tombstones | 1843 self._store_tombstones = store_tombstones |
| 1836 self._result_details = result_details | 1844 self._result_details = result_details |
| 1845 self._render_results_dir = render_results_dir |
| 1837 self._args = args | 1846 self._args = args |
| 1838 | 1847 |
| 1839 @property | 1848 @property |
| 1840 def uses_local_devices(self): | 1849 def uses_local_devices(self): |
| 1841 return True | 1850 return True |
| 1842 | 1851 |
| 1843 #override | 1852 #override |
| 1844 def run_tests(self, api, suffix, json_results_file): | 1853 def run_tests(self, api, suffix, json_results_file): |
| 1845 api.chromium_android.run_instrumentation_suite( | 1854 return api.chromium_android.run_instrumentation_suite( |
| 1846 self.name, | 1855 self.name, |
| 1847 test_apk=api.chromium_android.apk_path(self._test_apk), | 1856 test_apk=api.chromium_android.apk_path(self._test_apk), |
| 1848 apk_under_test=api.chromium_android.apk_path(self._apk_under_test), | 1857 apk_under_test=api.chromium_android.apk_path(self._apk_under_test), |
| 1849 additional_apks=[ | 1858 additional_apks=[ |
| 1850 api.chromium_android.apk_path(a) | 1859 api.chromium_android.apk_path(a) |
| 1851 for a in self._additional_apks or []], | 1860 for a in self._additional_apks or []], |
| 1852 suffix=suffix, | 1861 suffix=suffix, |
| 1853 annotation=self._annotation, except_annotation=self._except_annotation, | 1862 annotation=self._annotation, except_annotation=self._except_annotation, |
| 1854 screenshot=self._screenshot, verbose=self._verbose, tool=self._tool, | 1863 screenshot=self._screenshot, verbose=self._verbose, tool=self._tool, |
| 1855 json_results_file=json_results_file, | 1864 json_results_file=json_results_file, |
| 1856 timeout_scale=self._timeout_scale, | 1865 timeout_scale=self._timeout_scale, |
| 1857 result_details=self._result_details, | 1866 result_details=self._result_details, |
| 1858 store_tombstones=self._store_tombstones, | 1867 store_tombstones=self._store_tombstones, |
| 1859 wrapper_script_suite_name=self._wrapper_script_suite_name, | 1868 wrapper_script_suite_name=self._wrapper_script_suite_name, |
| 1869 render_results_dir=self._render_results_dir, |
| 1860 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False
), | 1870 step_test_data=lambda: api.test_utils.test_api.canned_gtest_output(False
), |
| 1861 args=self._args) | 1871 args=self._args) |
| 1862 | 1872 |
| 1863 | 1873 |
| 1864 class BlinkTest(Test): | 1874 class BlinkTest(Test): |
| 1865 # TODO(dpranke): This should be converted to a PythonBasedTest, although it | 1875 # TODO(dpranke): This should be converted to a PythonBasedTest, although it |
| 1866 # will need custom behavior because we archive the results as well. | 1876 # will need custom behavior because we archive the results as well. |
| 1867 def __init__(self, extra_args=None): | 1877 def __init__(self, extra_args=None): |
| 1868 super(BlinkTest, self).__init__() | 1878 super(BlinkTest, self).__init__() |
| 1869 self._extra_args = extra_args | 1879 self._extra_args = extra_args |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 args=args) | 2119 args=args) |
| 2110 api.gsutil.upload( | 2120 api.gsutil.upload( |
| 2111 temp_output_dir.join( | 2121 temp_output_dir.join( |
| 2112 '%s-android-chrome.json' % timestamp_string), | 2122 '%s-android-chrome.json' % timestamp_string), |
| 2113 'chromium-annotated-tests', 'android') | 2123 'chromium-annotated-tests', 'android') |
| 2114 | 2124 |
| 2115 GOMA_TESTS = [ | 2125 GOMA_TESTS = [ |
| 2116 GTestTest('base_unittests'), | 2126 GTestTest('base_unittests'), |
| 2117 GTestTest('content_unittests'), | 2127 GTestTest('content_unittests'), |
| 2118 ] | 2128 ] |
| OLD | NEW |