OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2016 Google Inc. | 3 # Copyright 2016 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 | 8 |
9 """Default flavor utils class, used for desktop bots.""" | 9 """Default flavor utils class, used for desktop bots.""" |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 for that flavor. | 64 for that flavor. |
65 | 65 |
66 For example, the AndroidFlavorUtils will override the functions for | 66 For example, the AndroidFlavorUtils will override the functions for |
67 copying files between the host and Android device, as well as the | 67 copying files between the host and Android device, as well as the |
68 'step' function, so that commands may be run through ADB. | 68 'step' function, so that commands may be run through ADB. |
69 """ | 69 """ |
70 def __init__(self, bot_info, *args, **kwargs): | 70 def __init__(self, bot_info, *args, **kwargs): |
71 self._bot_info = bot_info | 71 self._bot_info = bot_info |
72 self.chrome_path = os.path.join(os.path.expanduser('~'), 'src') | 72 self.chrome_path = os.path.join(os.path.expanduser('~'), 'src') |
73 | 73 |
74 def step(self, cmd, **kwargs): | 74 def run(self, cmd, **kwargs): |
75 """Runs a step as appropriate for this flavor.""" | 75 """Runs a step as appropriate for this flavor.""" |
76 path_to_app = self._bot_info.out_dir.join( | 76 path_to_app = os.path.join(self._bot_info.out_dir, |
77 self._bot_info.configuration, cmd[0]) | 77 self._bot_info.configuration, cmd[0]) |
78 if (sys.platform == 'linux' and | 78 if (sys.platform == 'linux' and |
79 'x86_64' in self._bot_info.bot_name and | 79 'x86_64' in self._bot_info.bot_name and |
80 not 'TSAN' in self._bot_info.bot_name): | 80 not 'TSAN' in self._bot_info.bot_name): |
81 new_cmd = ['catchsegv', path_to_app] | 81 new_cmd = ['catchsegv', path_to_app] |
82 else: | 82 else: |
83 new_cmd = [path_to_app] | 83 new_cmd = [path_to_app] |
84 new_cmd.extend(cmd[1:]) | 84 new_cmd.extend(cmd[1:]) |
85 return self._bot_info.run(new_cmd, **kwargs) | 85 return self._bot_info.run(new_cmd, **kwargs) |
86 | 86 |
87 | 87 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 'from host to device is undefined and only allowed if ' | 134 'from host to device is undefined and only allowed if ' |
135 'host_path and device_path are the same (%s vs %s).' % ( | 135 'host_path and device_path are the same (%s vs %s).' % ( |
136 str(host_path), str(device_path))) | 136 str(host_path), str(device_path))) |
137 | 137 |
138 def create_clean_device_dir(self, path): | 138 def create_clean_device_dir(self, path): |
139 """Like shutil.rmtree() + os.makedirs(), but on a connected device.""" | 139 """Like shutil.rmtree() + os.makedirs(), but on a connected device.""" |
140 self.create_clean_host_dir(path) | 140 self.create_clean_host_dir(path) |
141 | 141 |
142 def create_clean_host_dir(self, path): | 142 def create_clean_host_dir(self, path): |
143 """Convenience function for creating a clean directory.""" | 143 """Convenience function for creating a clean directory.""" |
144 shutil.rmtree(path) | 144 if os.path.exists(path): |
| 145 shutil.rmtree(path) |
145 os.makedirs(path) | 146 os.makedirs(path) |
146 | 147 |
147 def install(self): | 148 def install(self): |
148 """Run device-specific installation steps.""" | 149 """Run device-specific installation steps.""" |
149 pass | 150 pass |
150 | 151 |
151 def cleanup_steps(self): | 152 def cleanup_steps(self): |
152 """Run any device-specific cleanup steps.""" | 153 """Run any device-specific cleanup steps.""" |
153 pass | 154 pass |
154 | 155 |
155 def get_device_dirs(self): | 156 def get_device_dirs(self): |
156 """ Set the directories which will be used by the build steps. | 157 """ Set the directories which will be used by the build steps. |
157 | 158 |
158 These refer to paths on the same device where the test executables will | 159 These refer to paths on the same device where the test executables will |
159 run, for example, for Android bots these are paths on the Android device | 160 run, for example, for Android bots these are paths on the Android device |
160 itself. For desktop bots, these are just local paths. | 161 itself. For desktop bots, these are just local paths. |
161 """ | 162 """ |
162 join = lambda p: os.path.join(self._bot_info.build_dir, p) | 163 join = lambda p: os.path.join(self._bot_info.build_dir, p) |
163 return DeviceDirs( | 164 return DeviceDirs( |
164 dm_dir=join('dm'), | 165 dm_dir=os.path.join(self._bot_info.swarm_out_dir, 'dm'), |
165 perf_data_dir=self._bot_info.perf_data_dir, | 166 perf_data_dir=self._bot_info.perf_data_dir, |
166 resource_dir=self._bot_info.resource_dir, | 167 resource_dir=self._bot_info.resource_dir, |
167 images_dir=join('images'), | 168 images_dir=join('images'), |
168 skp_dir=self._bot_info.local_skp_dir, | 169 skp_dir=self._bot_info.local_skp_dir, |
169 tmp_dir=join('tmp')) | 170 tmp_dir=join('tmp')) |
170 | 171 |
171 def __repr__(self): | 172 def __repr__(self): |
172 return '<%s object>' % self.__class__.__name__ # pragma: no cover | 173 return '<%s object>' % self.__class__.__name__ # pragma: no cover |
OLD | NEW |