Add default trybots for WebRTC try server.
Today, our tryjobs default to run on all trybots since
we don't have any default list configured in PRESUBMIT.py.
Because of this, the --testfilter argument doesn't work
unless you also specify --bot when sending the tryjob.
With this CL, it is possible to use --testfilter without
--bot.
It also gets the benefit of excluding unnecessary bots
when doing platform-specific changes.
Most of the code is copied from Chromium's src/PRESUBMIT.py:
https://code.google.com/p/chromium/codesearch#chromium/src/PRESUBMIT.py&l=1030
TEST=tested submitting a tryjob with git try -t compile.
BUG=none
R=andrew@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/2619004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5016 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index b8a702f..433cdce 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -6,6 +6,9 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
+import re
+
+
def _CheckNoIOStreamInHeaders(input_api, output_api):
"""Checks to make sure no .h files include <iostream>."""
files = []
@@ -150,3 +153,42 @@
results.extend(input_api.canned_checks.CheckChangeHasTestField(
input_api, output_api))
return results
+
+# pylint: disable=W0613
+def GetPreferredTrySlaves(project, change):
+ files = change.LocalPaths()
+
+ ios_bots = [
+ 'ios',
+ 'ios_rel',
+ ]
+ linux_bots = [
+ 'linux',
+ 'linux_asan',
+ 'linux_memcheck',
+ 'linux_rel',
+ 'linux_tsan',
+ ]
+ mac_bots = [
+ 'mac',
+ 'mac_asan',
+ 'mac_rel',
+ 'mac_x64_rel',
+ ]
+ win_bots = [
+ 'win',
+ 'win_rel',
+ 'win_x64_rel',
+ ]
+
+ if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files):
+ return []
+
+ if all(re.search('[/_]ios[/_.]', f) for f in files):
+ return ios_bots
+ if all(re.search('\.(m|mm)$|(^|[/_])mac[/_.]', f) for f in files):
+ return mac_bots
+ if all(re.search('(^|[/_])win[/_.]', f) for f in files):
+ return win_bots
+
+ return ['android_ndk'] + ios_bots + linux_bots + mac_bots + win_bots