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.
23 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26 Use pychecker to catch various Python coding errors.
35 test
= TestSCons
.TestSCons()
37 test
.skip_test('Not ready for clean pychecker output; skipping test.\n')
42 pychecker
= test
.where_is('pychecker')
44 test
.skip_test("Could not find 'pychecker'; skipping test(s).\n")
46 default_arguments
= []
48 pychecker
= os
.path
.join(os
.path
.split(pychecker
.__file
__)[0], 'checker.py')
49 program
= sys
.executable
50 default_arguments
= [pychecker
]
53 cwd
= os
.environ
['SCONS_CWD']
55 src_engine
= os
.environ
['SCONS_LIB_DIR']
57 src_engine
= os
.path
.join(cwd
, 'build', 'scons-src', 'src', 'engine')
58 if not os
.path
.exists(src_engine
):
59 src_engine
= os
.path
.join(cwd
, 'src', 'engine')
61 src_engine_
= os
.path
.join(src_engine
, '')
63 MANIFEST
= os
.path
.join(src_engine
, 'MANIFEST.in')
64 with
open(MANIFEST
) as f
:
65 files
= f
.read().split()
67 files
= [f
for f
in files
if f
[-3:] == '.py']
70 'SCons/compat/__init__.py',
71 'SCons/compat/_scons_UserString.py',
72 'SCons/compat/_scons_hashlib.py',
73 'SCons/compat/_scons_sets.py',
74 'SCons/compat/_scons_subprocess.py',
75 'SCons/compat/builtins.py',
86 files
= sorted(u
.keys())
90 default_arguments
.extend([
93 # Suppress warnings about unused arguments to functions and methods.
94 # We have too many wrapper functions that intentionally only use some
99 if sys
.platform
== 'win32':
100 default_arguments
.extend([
101 '--blacklist', '"pywintypes,pywintypes.error"',
104 per_file_arguments
= {
105 #'SCons/__init__.py' : [
107 # '"__revision__,__version__,__build__,__buildsys__,__date__,__developer__"',
111 pywintypes_warning
= "warning: couldn't find real module for class pywintypes.error (module name: pywintypes)\n"
113 os
.environ
['PYTHONPATH'] = src_engine
117 args
= (default_arguments
+
118 per_file_arguments
.get(file, []) +
119 [os
.path
.join(src_engine
, file)])
121 test
.run(program
=program
, arguments
=args
, status
=None, stderr
=None)
123 stdout
= test
.stdout()
124 stdout
= stdout
.replace(src_engine_
, '')
126 stderr
= test
.stderr()
127 stderr
= stderr
.replace(src_engine_
, '')
128 stderr
= stderr
.replace(pywintypes_warning
, '')
130 if test
.status
or stdout
or stderr
:
131 mismatches
.append('\n')
132 mismatches
.append(' '.join([program
] + args
) + '\n')
134 mismatches
.append('STDOUT =====================================\n')
135 mismatches
.append(stdout
)
138 mismatches
.append('STDERR =====================================\n')
139 mismatches
.append(stderr
)
142 print(''.join(mismatches
[1:]))
149 # indent-tabs-mode:nil
151 # vim: set expandtab tabstop=4 shiftwidth=4: