| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Unit tests for owners.py.""" | 6 """Unit tests for owners.py.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import unittest | 10 import unittest |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 # Check that the files are under the root. | 228 # Check that the files are under the root. |
| 229 db.root = '/checkout' | 229 db.root = '/checkout' |
| 230 self.assertRaises(AssertionError, db.reviewers_for, ['/OWNERS']) | 230 self.assertRaises(AssertionError, db.reviewers_for, ['/OWNERS']) |
| 231 | 231 |
| 232 def test_reviewers_for__wildcard_dir(self): | 232 def test_reviewers_for__wildcard_dir(self): |
| 233 self.assert_reviewers_for(['DEPS'], [owners.EVERYONE]) | 233 self.assert_reviewers_for(['DEPS'], [owners.EVERYONE]) |
| 234 | 234 |
| 235 def test_reviewers_for__one_owner(self): | 235 def test_reviewers_for__one_owner(self): |
| 236 self.assert_reviewers_for([ | 236 self.assert_reviewers_for([ |
| 237 '/chrome/gpu/gpu_channel.h', | 237 'chrome/gpu/gpu_channel.h', |
| 238 '/content/baz/froboz.h', | 238 'content/baz/froboz.h', |
| 239 '/chrome/renderer/gpu/gpu_channel_host.h'], [brett]) | 239 'chrome/renderer/gpu/gpu_channel_host.h'], [brett]) |
| 240 | 240 |
| 241 def test_reviewers_for__two_owners(self): | 241 def test_reviewers_for__two_owners(self): |
| 242 self.assert_reviewers_for([ | 242 self.assert_reviewers_for([ |
| 243 '/chrome/gpu/gpu_channel.h', | 243 'chrome/gpu/gpu_channel.h', |
| 244 '/content/content.gyp', | 244 'content/content.gyp', |
| 245 '/content/baz/froboz.h', | 245 'content/baz/froboz.h', |
| 246 '/content/views/pie.h' | 246 'content/views/pie.h' |
| 247 ], [john, brett]) | 247 ], [john, brett]) |
| 248 | 248 |
| 249 def test_reviewers_for__all_files(self): | 249 def test_reviewers_for__all_files(self): |
| 250 self.assert_reviewers_for([ | 250 self.assert_reviewers_for([ |
| 251 '/chrome/gpu/gpu_channel.h', | 251 'chrome/gpu/gpu_channel.h', |
| 252 '/chrome/renderer/gpu/gpu_channel_host.h', | 252 'chrome/renderer/gpu/gpu_channel_host.h', |
| 253 '/chrome/renderer/safe_browsing/scorer.h', | 253 'chrome/renderer/safe_browsing/scorer.h', |
| 254 '/content/content.gyp', | 254 'content/content.gyp', |
| 255 '/content/bar/foo.cc', | 255 'content/bar/foo.cc', |
| 256 '/content/baz/froboz.h', | 256 'content/baz/froboz.h', |
| 257 '/content/views/pie.h'], [john, brett]) | 257 'content/views/pie.h'], [john, brett]) |
| 258 |
| 259 def test_reviewers_for__per_file_owners_file(self): |
| 260 self.files['/content/baz/OWNERS'] = owners_file(lines=[ |
| 261 'per-file ugly.*=tom@example.com']) |
| 262 self.assert_reviewers_for(['content/baz/OWNERS'], [darin]) |
| 258 | 263 |
| 259 def assert_syntax_error(self, owners_file_contents): | 264 def assert_syntax_error(self, owners_file_contents): |
| 260 db = self.db() | 265 db = self.db() |
| 261 self.files['/foo/OWNERS'] = owners_file_contents | 266 self.files['/foo/OWNERS'] = owners_file_contents |
| 262 self.files['/foo/DEPS'] = '' | 267 self.files['/foo/DEPS'] = '' |
| 263 try: | 268 try: |
| 264 db.reviewers_for(['/foo/DEPS']) | 269 db.reviewers_for(['foo/DEPS']) |
| 265 self.fail() # pragma: no cover | 270 self.fail() # pragma: no cover |
| 266 except owners.SyntaxErrorInOwnersFile, e: | 271 except owners.SyntaxErrorInOwnersFile, e: |
| 267 self.assertTrue(str(e).startswith('/foo/OWNERS:1')) | 272 self.assertTrue(str(e).startswith('/foo/OWNERS:1')) |
| 268 | 273 |
| 269 def test_syntax_error__unknown_token(self): | 274 def test_syntax_error__unknown_token(self): |
| 270 self.assert_syntax_error('{}\n') | 275 self.assert_syntax_error('{}\n') |
| 271 | 276 |
| 272 def test_syntax_error__unknown_set(self): | 277 def test_syntax_error__unknown_set(self): |
| 273 self.assert_syntax_error('set myfatherisbillgates\n') | 278 self.assert_syntax_error('set myfatherisbillgates\n') |
| 274 | 279 |
| 275 def test_syntax_error__bad_email(self): | 280 def test_syntax_error__bad_email(self): |
| 276 self.assert_syntax_error('ben\n') | 281 self.assert_syntax_error('ben\n') |
| 277 | 282 |
| 278 | 283 |
| 279 if __name__ == '__main__': | 284 if __name__ == '__main__': |
| 280 unittest.main() | 285 unittest.main() |
| OLD | NEW |