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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify that we have proper strings like Copyright notices on all the
29 right files in our distributions.
31 Note that this is a source file and packaging test, not a functional test,
32 so the name of this script doesn't end in *Tests.py.
44 # Use TestCmd, not TestSCons, so we don't chdir to a temporary directory.
45 test = TestCmd.TestCmd()
47 scons_version = TestSCons.SConsVersion
49 def build_path(*args):
50 return apply(os.path.join, ('build',)+args)
52 build_scons = build_path('scons')
53 build_local = build_path('scons-local', 'scons-local-'+scons_version)
54 build_src = build_path('scons-src')
57 def __init__(self, directory,
60 remove_patterns = []):
61 self.directory = directory
62 self.search_list = search_list
65 self.remove_dict[os.path.join(directory, r)] = 1
66 self.remove_patterns = remove_patterns
68 def directory_exists(self):
69 return os.path.exists(self.directory)
71 def remove_this(self, name, path):
72 if self.remove_dict.get(path):
75 for pattern in self.remove_patterns:
76 if fnmatch.fnmatch(name, pattern):
80 def search_this(self, path):
82 for pattern in self.search_list:
83 if fnmatch.fnmatch(path, pattern):
87 return os.path.isfile(path)
89 def visit(self, result, dirname, names):
90 make_path_tuple = lambda n, d=dirname: (n, os.path.join(d, n))
91 for name, path in map(make_path_tuple, names):
92 if self.remove_this(name, path):
94 elif self.search_this(path):
95 body = open(path, 'r').read()
96 for expr in self.expressions:
97 if not expr.search(body):
98 msg = '%s: missing %s' % (path, repr(expr.pattern))
101 def find_missing(self):
103 os.path.walk(self.directory, self.visit, result)
106 class CheckUnexpandedStrings(Checker):
108 re.compile('__COPYRIGHT__'),
109 re.compile('__FILE__ __REVISION__ __DATE__ __DEVELOPER__'),
111 def must_be_built(self):
114 class CheckExpandedCopyright(Checker):
116 re.compile('Copyright.*The SCons Foundation'),
118 def must_be_built(self):
123 CheckUnexpandedStrings(
125 search_list = [ '*.py' ],
127 'engine/SCons/compat/_scons_sets.py',
128 'engine/SCons/compat/_scons_sets15.py',
129 'engine/SCons/compat/_scons_subprocess.py',
130 'engine/SCons/Conftest.py',
131 'engine/SCons/dblite.py',
132 'engine/SCons/Optik',
136 CheckUnexpandedStrings(
138 search_list = [ '*.py' ],
141 CheckExpandedCopyright(
150 'engine/SCons/compat/_scons_sets.py',
151 'engine/SCons/compat/_scons_sets15.py',
152 'engine/SCons/compat/_scons_subprocess.py',
153 'engine/SCons/Conftest.py',
154 'engine/SCons/dblite.py',
155 'engine/SCons/Optik',
157 'os_spawnv_fix.diff',
160 # We run epydoc on the *.py files, which generates *.pyc files.
166 CheckExpandedCopyright(
169 'SCons/compat/_scons_sets.py',
170 'SCons/compat/_scons_sets15.py',
171 'SCons/compat/_scons_subprocess.py',
178 CheckExpandedCopyright(
189 'doc/developer/MANIFEST',
193 'doc/user/SCons-win32-install-1.jpg',
194 'doc/user/SCons-win32-install-2.jpg',
195 'doc/user/SCons-win32-install-3.jpg',
196 'doc/user/SCons-win32-install-4.jpg',
198 'QMTest/classes.qmc',
199 'QMTest/configuration',
201 'QMTest/TestCommon.py',
202 'QMTest/unittest.py',
203 'src/os_spawnv_fix.diff',
206 'src/engine/MANIFEST.in',
207 'src/engine/MANIFEST-xml.in',
208 'src/engine/setup.cfg',
209 'src/engine/SCons/compat/_scons_sets.py',
210 'src/engine/SCons/compat/_scons_sets15.py',
211 'src/engine/SCons/compat/_scons_subprocess.py',
212 'src/engine/SCons/Conftest.py',
213 'src/engine/SCons/dblite.py',
214 'src/engine/SCons/Optik',
215 'src/script/MANIFEST.in',
216 'src/script/setup.cfg',
225 for collector in check_list:
226 if collector.directory_exists():
227 missing_strings.extend(collector.find_missing())
228 elif collector.must_be_built():
229 not_built.append(collector.directory)
232 print "Found the following files with missing strings:"
233 print "\t" + string.join(missing_strings, "\n\t")
237 print "Cannot check all strings, the following have apparently not been built:"
238 print "\t" + string.join(not_built, "\n\t")