5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
26 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
29 Use pychecker to catch various Python coding errors.
38 test = TestSCons.TestSCons()
40 test.skip_test('Not ready for clean pychecker output; skipping test.\n')
45 pychecker = test.where_is('pychecker')
47 test.skip_test("Could not find 'pychecker'; skipping test(s).\n")
49 default_arguments = []
51 pychecker = os.path.join(os.path.split(pychecker.__file__)[0], 'checker.py')
52 program = sys.executable
53 default_arguments = [pychecker]
56 cwd = os.environ['SCONS_CWD']
58 src_engine = os.environ['SCONS_LIB_DIR']
60 src_engine = os.path.join(cwd, 'build', 'scons-src', 'src', 'engine')
61 if not os.path.exists(src_engine):
62 src_engine = os.path.join(cwd, 'src', 'engine')
64 src_engine_ = os.path.join(src_engine, '')
66 MANIFEST = os.path.join(src_engine, 'MANIFEST.in')
67 files = open(MANIFEST).read().split()
69 files = [f for f in files if f[-3:] == '.py']
72 'SCons/compat/__init__.py',
73 'SCons/compat/_scons_UserString.py',
74 'SCons/compat/_scons_hashlib.py',
75 'SCons/compat/_scons_itertools.py',
76 'SCons/compat/_scons_optparse.py',
77 'SCons/compat/_scons_sets.py',
78 'SCons/compat/_scons_sets15.py',
79 'SCons/compat/_scons_shlex.py',
80 'SCons/compat/_scons_subprocess.py',
81 'SCons/compat/_scons_textwrap.py',
82 'SCons/compat/builtins.py',
100 default_arguments.extend([
103 # Suppress warnings about unused arguments to functions and methods.
104 # We have too many wrapper functions that intentionally only use some
105 # of their arguments.
109 if sys.platform == 'win32':
110 default_arguments.extend([
111 '--blacklist', '"pywintypes,pywintypes.error"',
114 per_file_arguments = {
115 #'SCons/__init__.py' : [
117 # '"__revision__,__version__,__build__,__buildsys__,__date__,__developer__"',
121 pywintypes_warning = "warning: couldn't find real module for class pywintypes.error (module name: pywintypes)\n"
123 os.environ['PYTHONPATH'] = src_engine
127 args = (default_arguments +
128 per_file_arguments.get(file, []) +
129 [os.path.join(src_engine, file)])
131 test.run(program=program, arguments=args, status=None, stderr=None)
133 stdout = test.stdout()
134 stdout = stdout.replace(src_engine_, '')
136 stderr = test.stderr()
137 stderr = stderr.replace(src_engine_, '')
138 stderr = stderr.replace(pywintypes_warning, '')
140 if test.status or stdout or stderr:
141 mismatches.append('\n')
142 mismatches.append(' '.join([program] + args) + '\n')
144 mismatches.append('STDOUT =====================================\n')
145 mismatches.append(stdout)
148 mismatches.append('STDERR =====================================\n')
149 mismatches.append(stderr)
152 print ''.join(mismatches[1:])
159 # indent-tabs-mode:nil
161 # vim: set expandtab tabstop=4 shiftwidth=4: