Bug 1403519: reset SCHEDULES.exclusive if set multiple times; r=gps

MozReview-Commit-ID: Kycd9i5f19P

--HG--
extra : rebase_source : 9d9557f82982f0ef2605645db28adf68289e1cfa
This commit is contained in:
Dustin J. Mitchell 2018-01-16 22:33:08 +00:00
parent 26d48b3202
commit 74237a9cc3
4 changed files with 17 additions and 12 deletions

View File

@ -848,10 +848,9 @@ class Schedules(object):
elif other._exclusive == schedules.EXCLUSIVE_COMPONENTS:
rv._exclusive = self._exclusive
else:
msg = 'Two Files sections have set SCHEDULES.exclusive to different' \
'values; these cannot be combined: {} and {}'
msg = msg.format(self._exclusive, other._exclusive)
raise ValueError(msg)
# in a case where two SCHEDULES.exclusive set different values, take
# the later one; this acts the way we expect assignment to work.
rv._exclusive = other._exclusive
return rv

View File

@ -7,7 +7,7 @@ with Files('*.win'):
with Files('*.osx'):
SCHEDULES.exclusive = ['macosx']
with Files('bad.osx'):
with Files('win.and.osx'):
# this conflicts with the previous clause and will cause an error
# when read
SCHEDULES.exclusive = ['macosx', 'windows']

View File

@ -484,6 +484,7 @@ class TestBuildReader(unittest.TestCase):
def test_schedules(self):
reader = self.reader('schedules')
info = reader.files_info([
'win.and.osx',
'somefile',
'foo.win',
'foo.osx',
@ -513,13 +514,10 @@ class TestBuildReader(unittest.TestCase):
self.assertEqual(set(info['subd/yaml.py']['SCHEDULES'].components),
set(schedules.EXCLUSIVE_COMPONENTS + ['py-lint', 'yaml-lint']))
def test_schedules_conflicting_excludes(self):
reader = self.reader('schedules')
# bad.osx is defined explicitly, and matches *.osx, and the two have
# conflicting SCHEDULES.exclusive settings
with self.assertRaisesRegexp(ValueError, r"Two Files sections"):
reader.files_info(['bad.osx'])
# win.and.osx is defined explicitly, and matches *.osx, and the two have
# conflicting SCHEDULES.exclusive settings, so the later one is used
self.assertEqual(set(info['win.and.osx']['SCHEDULES'].exclusive),
set(['macosx', 'windows']))
if __name__ == '__main__':
main()

View File

@ -78,6 +78,14 @@ For cases where an inclusive component is affected exclusively (such as the pyth
with Files('**/pep8rc'):
SCHEDULES.exclusive = ['py-lint']
If multiple stanzas set ``SCHEDULES.exclusive``, the last one will take precedence. Thus the following will set ``SCHEDULES.exclusive`` to ``hpux`` for all files except those under ``docs/``.
with Files('**'):
SCHEDULES.exclusive = ['hpux']
with Files('**/docs'):
SCHEDULES.exclusive = ['docs']
Task Annotation
:::::::::::::::