OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import unittest |
| 6 import os |
| 7 |
| 8 from gpu_tests import path_util |
| 9 |
| 10 path_util.AddDirToPathIfNeeded( |
| 11 path_util.GetChromiumSrcDir(), 'third_party', 'logilab') |
| 12 |
| 13 path_util.AddDirToPathIfNeeded( |
| 14 path_util.GetChromiumSrcDir(), 'third_party', 'logilab', 'logilab') |
| 15 |
| 16 path_util.AddDirToPathIfNeeded( |
| 17 path_util.GetChromiumSrcDir(), 'third_party', 'pylint') |
| 18 |
| 19 try: |
| 20 from pylint import lint |
| 21 except ImportError: |
| 22 lint = None |
| 23 |
| 24 |
| 25 _RC_FILE = os.path.join(path_util.GetGpuTestDir(), 'pylintrc') |
| 26 |
| 27 def LintCheckPassed(directory): |
| 28 args = [directory, '--rcfile=%s' % _RC_FILE] |
| 29 try: |
| 30 assert lint, 'pylint module cannot be found' |
| 31 lint.Run(args) |
| 32 assert False, ( |
| 33 'This should not be reached as lint.Run always raise SystemExit') |
| 34 except SystemExit as err: |
| 35 if err.code == 0: |
| 36 return True |
| 37 return False |
| 38 |
| 39 |
| 40 class LintTest(unittest.TestCase): |
| 41 |
| 42 def testPassingPylintCheckForGpuTestsDir(self): |
| 43 self.assertTrue(LintCheckPassed(os.path.abspath(os.path.dirname(__file__)))) |
| 44 |
| 45 def testPassingPylintCheckForPageSetsDir(self): |
| 46 self.assertTrue(LintCheckPassed( |
| 47 os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'page_sets' |
| 48 ))) |
OLD | NEW |