diff --git a/presubmit_support.py b/presubmit_support.py index 5bd049bcd..0b72f4656 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -926,6 +926,9 @@ class GetTrySlavesExecuter(object): if item != item.strip(): raise PresubmitFailure( 'Try slave names cannot start/end with whitespace') + if ',' in item: + raise PresubmitFailure( + 'Do not use \',\' separated builder or test names: %s' % item) else: result = [] return result diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 84585e993..6c85ac95f 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -792,6 +792,25 @@ def CheckChangeOnCommit(input_api, output_api): self.fake_root_dir, None, None, False, output)) + def testGetTrySlavesExecuter_ok(self): + script_text = ( + 'def GetPreferredTrySlaves():\n' + ' return ["foo", "bar"]\n') + results = presubmit.GetTrySlavesExecuter.ExecPresubmitScript( + script_text, 'path', 'project', None) + self.assertEquals(['foo', 'bar'], results) + + def testGetTrySlavesExecuter_comma(self): + script_text = ( + 'def GetPreferredTrySlaves():\n' + ' return ["foo,bar"]\n') + try: + presubmit.GetTrySlavesExecuter.ExecPresubmitScript( + script_text, 'path', 'project', None) + self.fail() + except presubmit.PresubmitFailure: + pass + def testMainUnversioned(self): # OptParser calls presubmit.os.path.exists and is a pain when mocked. self.UnMock(presubmit.os.path, 'exists') diff --git a/trychange.py b/trychange.py index 748dbfa6c..e37347c67 100755 --- a/trychange.py +++ b/trychange.py @@ -805,6 +805,16 @@ def TryChange(argv, sys.stdout) except ImportError: pass + if options.testfilter: + bots = set() + for bot in options.bot: + assert ',' not in bot + if bot.endswith(':compile'): + # Skip over compile-only builders for now. + continue + bots.add(bot.split(':', 1)[0]) + options.bot = list(bots) + # If no bot is specified, either the default pool will be selected or the # try server will refuse the job. Either case we don't need to interfere.