| 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 presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1101,E1103 | 8 # pylint: disable=E1101,E1103 |
| 9 | 9 |
| 10 import logging | 10 import logging |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 input_api.tbr = False | 1450 input_api.tbr = False |
| 1451 input_api.python_executable = 'pyyyyython' | 1451 input_api.python_executable = 'pyyyyython' |
| 1452 input_api.platform = sys.platform | 1452 input_api.platform = sys.platform |
| 1453 input_api.time = time | 1453 input_api.time = time |
| 1454 input_api.canned_checks = presubmit_canned_checks | 1454 input_api.canned_checks = presubmit_canned_checks |
| 1455 return input_api | 1455 return input_api |
| 1456 | 1456 |
| 1457 def testMembersChanged(self): | 1457 def testMembersChanged(self): |
| 1458 self.mox.ReplayAll() | 1458 self.mox.ReplayAll() |
| 1459 members = [ | 1459 members = [ |
| 1460 'CheckBuildbotPendingBuilds', | 1460 'CheckBuildbotPendingBuilds', |
| 1461 'CheckChangeHasBugField', 'CheckChangeHasDescription', | 1461 'CheckChangeHasBugField', |
| 1462 'CheckChangeHasNoStrayWhitespace', | 1462 'CheckChangeHasDescription', |
| 1463 'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR', | 1463 'CheckChangeHasNoCR', |
| 1464 'CheckChangeHasNoCrAndHasOnlyOneEol', 'CheckChangeHasNoTabs', | 1464 'CheckChangeHasNoCrAndHasOnlyOneEol', |
| 1465 'CheckChangeTodoHasOwner', | 1465 'CheckChangeHasNoStrayWhitespace', |
| 1466 'CheckChangeHasQaField', 'CheckChangeHasTestedField', | 1466 'CheckChangeHasNoTabs', |
| 1467 'CheckChangeHasTestField', | 1467 'CheckChangeHasOnlyOneEol', |
| 1468 'CheckChangeLintsClean', | 1468 'CheckChangeHasQaField', |
| 1469 'CheckChangeSvnEolStyle', | 1469 'CheckChangeHasTestedField', |
| 1470 'CheckChangeWasUploaded', | 1470 'CheckChangeHasTestField', |
| 1471 'CheckDoNotSubmit', | 1471 'CheckChangeLintsClean', |
| 1472 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', | 1472 'CheckChangeSvnEolStyle', |
| 1473 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', | 1473 'CheckChangeTodoHasOwner', |
| 1474 'CheckLicense', | 1474 'CheckChangeWasUploaded', |
| 1475 'CheckOwners', | 1475 'CheckDoNotSubmit', |
| 1476 'CheckRietveldTryJobExecution', | 1476 'CheckDoNotSubmitInDescription', |
| 1477 'CheckSvnModifiedDirectories', | 1477 'CheckDoNotSubmitInFiles', |
| 1478 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', | 1478 'CheckLicense', |
| 1479 'RunPythonUnitTests', 'RunPylint', | 1479 'CheckLongLines', 'CheckTreeIsOpen', |
| 1480 'RunUnitTests', 'RunUnitTestsInDirectory', | 1480 'CheckOwners', |
| 1481 'CheckRietveldTryJobExecution', |
| 1482 'CheckSvnForCommonMimeTypes', |
| 1483 'CheckSvnModifiedDirectories', |
| 1484 'CheckSvnProperty', |
| 1485 'CheckWebDevStyleGuide', |
| 1486 'PanProjectChecks', |
| 1487 're', |
| 1488 'RunPylint', |
| 1489 'RunPythonUnitTests', |
| 1490 'RunUnitTests', |
| 1491 'RunUnitTestsInDirectory', |
| 1481 ] | 1492 ] |
| 1482 # If this test fails, you should add the relevant test. | 1493 # If this test fails, you should add the relevant test. |
| 1483 self.compareMembers(presubmit_canned_checks, members) | 1494 self.compareMembers(presubmit_canned_checks, members) |
| 1484 | 1495 |
| 1485 def DescriptionTest(self, check, description1, description2, error_type, | 1496 def DescriptionTest(self, check, description1, description2, error_type, |
| 1486 committing): | 1497 committing): |
| 1487 change1 = presubmit.Change( | 1498 change1 = presubmit.Change( |
| 1488 'foo1', description1, self.fake_root_dir, None, 0, 0, None) | 1499 'foo1', description1, self.fake_root_dir, None, 0, 0, None) |
| 1489 input_api1 = self.MockInputApi(change1, committing) | 1500 input_api1 = self.MockInputApi(change1, committing) |
| 1490 change2 = presubmit.Change( | 1501 change2 = presubmit.Change( |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 excluded_paths=None, | 2290 excluded_paths=None, |
| 2280 text_files=None, | 2291 text_files=None, |
| 2281 license_header=None, | 2292 license_header=None, |
| 2282 project_name=None, | 2293 project_name=None, |
| 2283 owners_check=True) | 2294 owners_check=True) |
| 2284 self.assertEqual(1, len(results)) | 2295 self.assertEqual(1, len(results)) |
| 2285 self.assertEqual( | 2296 self.assertEqual( |
| 2286 'Found line ending with white spaces in:', results[0]._message) | 2297 'Found line ending with white spaces in:', results[0]._message) |
| 2287 self.checkstdout('') | 2298 self.checkstdout('') |
| 2288 | 2299 |
| 2300 def testCheckWebDevStyleGuide(self): |
| 2301 fake_file = 'fake.css' |
| 2302 fake_contents = """ |
| 2303 /* Comment */ |
| 2304 .badClass, #anotherSelector { |
| 2305 color:hsl(0, 5, 0%) #777777; |
| 2306 background: #369 0px 10px; /* comment */ } |
| 2307 |
| 2308 @media print /* |
| 2309 Comment. |
| 2310 */ |
| 2311 { |
| 2312 @-webkit-keyframe { |
| 2313 0% { |
| 2314 blah: blah; |
| 2315 } |
| 2316 0%{blar: blug;} |
| 2317 } |
| 2318 } /** comment **/ |
| 2319 |
| 2320 .app-contents:active:not(.suppress-active), |
| 2321 .app:not(.click-focus):focus .app-contents:not(.suppress-active), |
| 2322 html[dir="rtl"] .drag-representation:not(.placing) .app-contents { |
| 2323 border-radius: 10px; |
| 2324 -webkit-border-radius: 5px; |
| 2325 }""" |
| 2326 |
| 2327 change = presubmit.Change('fu', 'bar', self.fake_root_dir, None, 0, 0, None) |
| 2328 input_api = self.MockInputApi(change, False) |
| 2329 input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([fake_file]) |
| 2330 input_api.ReadFile(fake_file).MultipleTimes().AndReturn(fake_contents) |
| 2331 |
| 2332 self.mox.ReplayAll() |
| 2333 |
| 2334 output = presubmit_canned_checks._CheckWebDevStyleGuide( |
| 2335 input_api, presubmit.OutputApi, None) |
| 2336 |
| 2337 print "%s" % output |
| 2289 | 2338 |
| 2290 if __name__ == '__main__': | 2339 if __name__ == '__main__': |
| 2291 import unittest | 2340 import unittest |
| 2292 unittest.main() | 2341 unittest.main() |
| OLD | NEW |