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 re | 5 import re |
6 import string | 6 import string |
7 | 7 |
8 | 8 |
9 class Test(object): | 9 class Test(object): |
10 """ | 10 """ |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 def run_test_locally(self, api, suffix): | 798 def run_test_locally(self, api, suffix): |
799 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path) | 799 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path) |
800 if self._android_isolate_path else None) | 800 if self._android_isolate_path else None) |
801 AndroidInstrumentationTest( | 801 AndroidInstrumentationTest( |
802 name=self.name, | 802 name=self.name, |
803 compile_target=self._compile_target, | 803 compile_target=self._compile_target, |
804 adb_install_apk=self._apk_under_test, | 804 adb_install_apk=self._apk_under_test, |
805 isolate_file_path=isolate_file_path).run(api, suffix) | 805 isolate_file_path=isolate_file_path).run(api, suffix) |
806 | 806 |
807 | 807 |
808 class IsolatedScriptTest(Test): | |
809 def __init__(self, name, args=None, target_name=None, revision=None, | |
810 webkit_revision=None, override_compile_targets=None, | |
811 **runtest_kwargs): | |
812 """Constructs an instance of IsolatedScriptTest. | |
813 | |
814 An IsolatedScriptTest knows how to invoke an isolate which obeys a certain | |
815 contract. The isolate's main target must be a wrapper script which must | |
816 interpret certain command line arguments as follows: | |
817 | |
818 --test-launcher-summary-output [FILENAME] | |
819 | |
820 The wrapper script must write the simplified json output that the recipes | |
821 consume (similar to GTestTest and ScriptTest) into |FILENAME|. | |
822 | |
823 The contract may be expanded later to support functionality like sharding | |
824 and retries of specific failed tests. Currently the examples of such wrapper | |
825 scripts live in src/testing/scripts/ in the Chromium workspace. | |
826 | |
827 Args: | |
828 name: Displayed name of the test. May be modified by suffixes. | |
829 args: Arguments to be passed to the test. | |
830 target_name: Actual name of the test. Defaults to name. | |
831 revision: Revision of the Chrome checkout. | |
832 webkit_revision: Revision of the WebKit checkout. | |
833 override_compile_targets: List of compile targets for this test | |
834 (for tests that don't follow target naming conventions). | |
835 runtest_kwargs: Additional keyword args forwarded to the runtest. | |
836 """ | |
837 super(IsolatedScriptTest, self).__init__() | |
838 self._name = name | |
839 self._args = args or [] | |
840 self._target_name = target_name | |
841 self._revision = revision | |
842 self._webkit_revision = webkit_revision | |
843 self._override_compile_targets = override_compile_targets | |
844 self._runtest_kwargs = runtest_kwargs | |
845 | |
846 @property | |
847 def name(self): | |
848 return self._name | |
849 | |
850 @property | |
851 def target_name(self): | |
852 return self._target_name or self._name | |
853 | |
854 @property | |
855 def isolate_target(self): | |
Ken Russell (switch to Gerrit)
2015/09/15 01:41:16
I think we need to override the "uses_swarming" pr
| |
856 return self.target_name # pragma: no cover | |
857 | |
858 # TODO(nednguyen, kbr): figure out what to do with Android. | |
859 def compile_targets(self, api): | |
860 if self._override_compile_targets: | |
861 return self._override_compile_targets | |
862 | |
863 if api.chromium.c.TARGET_PLATFORM == 'android': | |
864 return [self.target_name + '_apk'] | |
865 | |
866 return [self.target_name] | |
867 | |
868 def run(self, api, suffix): | |
869 # Copy the list because run can be invoked multiple times and we modify | |
870 # the local copy. | |
871 args = self._args[:] | |
872 is_android = api.chromium.c.TARGET_PLATFORM == 'android' | |
873 | |
874 # TODO(nednguyen, kbr): figure out what to do with Android. | |
875 if is_android: | |
876 raise UnimplementedError | |
877 | |
878 kwargs = {} | |
879 # TODO(nednguyen, kbr): define contract with the wrapper script to rerun | |
880 # a subset of the tests. | |
881 # if suffix == 'without patch': | |
882 # failures = self.failures(api, 'with patch') | |
883 # if is_android: | |
884 # kwargs['gtest_filter'] = ':'.join(failures) # pragma: no cover | |
885 # else: | |
886 # args.append(api.chromium.test_launcher_filter(failures)) | |
887 | |
888 gtest_results_file = api.test_utils.gtest_results(add_json_log=False) | |
Ken Russell (switch to Gerrit)
2015/09/17 01:19:31
We should use api.json.output() here and a similar
| |
889 step_test_data = lambda: api.test_utils.test_api.canned_gtest_output(True) | |
890 | |
891 kwargs['name'] = self._step_name(suffix) | |
892 kwargs['args'] = args | |
893 kwargs['step_test_data'] = step_test_data | |
894 kwargs['xvfb'] = True | |
895 kwargs['test_type'] = self.name | |
896 kwargs['annotate'] = 'gtest' | |
897 kwargs['test_launcher_summary_output'] = gtest_results_file | |
898 kwargs.update(self._runtest_kwargs) | |
899 | |
900 try: | |
901 api.isolate.runtest(self.target_name, self._revision, | |
902 self._webkit_revision, **kwargs) | |
903 finally: | |
904 self._test_runs[suffix] = api.step.active_result | |
iannucci
2015/09/17 00:49:48
talked to kbr. I think what you want to do is swit
| |
905 if self.has_valid_results(api, suffix): | |
906 self._test_runs[suffix].presentation.step_text += ( | |
907 api.test_utils.format_step_text([ | |
908 ['failures:', self.failures(api, suffix)] | |
909 ])) | |
910 return self._test_runs[suffix] | |
911 | |
912 def has_valid_results(self, api, suffix): | |
913 try: | |
914 # Make sure the JSON includes all necessary data. | |
915 self.failures(api, suffix) | |
916 | |
917 return self._test_runs[suffix].json.output['valid'] | |
918 except Exception: # pragma: no cover | |
919 return False | |
920 | |
921 def failures(self, api, suffix): | |
922 return self._test_runs[suffix].json.output['failures'] | |
923 | |
924 | |
925 def generate_isolated_script(api, mastername, buildername, test_spec, | |
926 enable_swarming=False, | |
927 scripts_compile_targets=None): | |
928 for spec in test_spec.get(buildername, {}).get( | |
929 'isolated_scripts', []): | |
930 # TODO(kbr, nednguyen): figure out where revision & webkit_revision come | |
931 # from. | |
932 yield IsolatedScriptTest( | |
933 str(spec['name']), | |
934 args=spec.get('args', []), | |
935 target_name=spec['isolate_name']) | |
936 | |
937 | |
808 class GTestTest(Test): | 938 class GTestTest(Test): |
809 def __init__(self, name, args=None, target_name=None, enable_swarming=False, | 939 def __init__(self, name, args=None, target_name=None, enable_swarming=False, |
810 swarming_shards=1, swarming_dimensions=None, swarming_tags=None, | 940 swarming_shards=1, swarming_dimensions=None, swarming_tags=None, |
811 swarming_extra_suffix=None, **runtest_kwargs): | 941 swarming_extra_suffix=None, **runtest_kwargs): |
812 super(GTestTest, self).__init__() | 942 super(GTestTest, self).__init__() |
813 if enable_swarming: | 943 if enable_swarming: |
814 self._test = SwarmingGTestTest( | 944 self._test = SwarmingGTestTest( |
815 name, args, target_name, swarming_shards, swarming_dimensions, | 945 name, args, target_name, swarming_shards, swarming_dimensions, |
816 swarming_tags, swarming_extra_suffix) | 946 swarming_tags, swarming_extra_suffix) |
817 else: | 947 else: |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1459 def run(self, api, suffix): | 1589 def run(self, api, suffix): |
1460 api.chromium_android.coverage_report(upload=False) | 1590 api.chromium_android.coverage_report(upload=False) |
1461 api.chromium_android.get_changed_lines_for_revision() | 1591 api.chromium_android.get_changed_lines_for_revision() |
1462 api.chromium_android.incremental_coverage_report() | 1592 api.chromium_android.incremental_coverage_report() |
1463 | 1593 |
1464 | 1594 |
1465 GOMA_TESTS = [ | 1595 GOMA_TESTS = [ |
1466 GTestTest('base_unittests'), | 1596 GTestTest('base_unittests'), |
1467 GTestTest('content_unittests'), | 1597 GTestTest('content_unittests'), |
1468 ] | 1598 ] |
OLD | NEW |