From 738149c9bfb9965d013d01ef99f9bb1c2819e7e8 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Tue, 15 Jun 2010 14:28:22 +0000 Subject: Imported Upstream version 2.0.0 --- src/test_strings.py | 58 +++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) (limited to 'src/test_strings.py') diff --git a/src/test_strings.py b/src/test_strings.py index 0def9bb..ce48d4c 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -22,7 +22,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/test_strings.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/test_strings.py 5023 2010/06/14 22:05:46 scons" """ Verify that we have proper strings like Copyright notices on all the @@ -36,7 +36,6 @@ import fnmatch import os import os.path import re -import string import TestCmd import TestSCons @@ -47,13 +46,13 @@ test = TestCmd.TestCmd() scons_version = TestSCons.SConsVersion def build_path(*args): - return apply(os.path.join, ('build',)+args) + return os.path.join('build', *args) build_scons = build_path('scons') build_local = build_path('scons-local', 'scons-local-'+scons_version) build_src = build_path('scons-src') -class Checker: +class Checker(object): def __init__(self, directory, search_list = [], remove_list = [], @@ -86,27 +85,29 @@ class Checker: else: return os.path.isfile(path) - def visit(self, result, dirname, names): - make_path_tuple = lambda n, d=dirname: (n, os.path.join(d, n)) - for name, path in map(make_path_tuple, names): - if self.remove_this(name, path): - names.remove(name) - elif self.search_this(path): - body = open(path, 'r').read() - for expr in self.expressions: - if not expr.search(body): - msg = '%s: missing %s' % (path, repr(expr.pattern)) - result.append(msg) - def find_missing(self): result = [] - os.path.walk(self.directory, self.visit, result) + for dirpath, dirnames, filenames in os.walk(self.directory): + if '.svn' in dirnames: + dirnames.remove('.svn') + for dname in dirnames[:]: + dpath = os.path.join(dirpath, dname) + if self.remove_this(dname, dpath): + dirnames.remove(dname) + for fname in filenames: + fpath = os.path.join(dirpath, fname) + if self.search_this(fpath) and not self.remove_this(fname, fpath): + body = open(fpath, 'r').read() + for expr in self.expressions: + if not expr.search(body): + msg = '%s: missing %s' % (fpath, repr(expr.pattern)) + result.append(msg) return result class CheckUnexpandedStrings(Checker): expressions = [ re.compile('Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation'), - re.compile('src/test_strings.py 4720 2010/03/24 03:14:11 jars'), + re.compile('src/test_strings.py 5023 2010/06/14 22:05:46 scons'), ] def must_be_built(self): return None @@ -131,12 +132,8 @@ check_list = [ 'src', search_list = [ '*.py' ], remove_list = [ - 'engine/SCons/compat/_scons_optparse.py', 'engine/SCons/compat/_scons_sets.py', - 'engine/SCons/compat/_scons_sets15.py', - 'engine/SCons/compat/_scons_shlex.py', 'engine/SCons/compat/_scons_subprocess.py', - 'engine/SCons/compat/_scons_textwrap.py', 'engine/SCons/Conftest.py', 'engine/SCons/dblite.py', ], @@ -164,12 +161,8 @@ check_list = [ 'debian', 'dist', 'gentoo', - 'engine/SCons/compat/_scons_optparse.py', 'engine/SCons/compat/_scons_sets.py', - 'engine/SCons/compat/_scons_sets15.py', - 'engine/SCons/compat/_scons_shlex.py', 'engine/SCons/compat/_scons_subprocess.py', - 'engine/SCons/compat/_scons_textwrap.py', 'engine/SCons/Conftest.py', 'engine/SCons/dblite.py', 'MANIFEST', @@ -185,12 +178,8 @@ check_list = [ CheckExpandedCopyright( build_local, remove_list = [ - 'SCons/compat/_scons_optparse.py', 'SCons/compat/_scons_sets.py', - 'SCons/compat/_scons_sets15.py', - 'SCons/compat/_scons_shlex.py', 'SCons/compat/_scons_subprocess.py', - 'SCons/compat/_scons_textwrap.py', 'SCons/Conftest.py', 'SCons/dblite.py', 'scons-%s.egg-info' % scons_version, @@ -223,19 +212,14 @@ check_list = [ 'QMTest/configuration', 'QMTest/TestCmd.py', 'QMTest/TestCommon.py', - 'QMTest/unittest.py', 'src/os_spawnv_fix.diff', 'src/MANIFEST.in', 'src/setup.cfg', 'src/engine/MANIFEST.in', 'src/engine/MANIFEST-xml.in', 'src/engine/setup.cfg', - 'src/engine/SCons/compat/_scons_optparse.py', 'src/engine/SCons/compat/_scons_sets.py', - 'src/engine/SCons/compat/_scons_sets15.py', - 'src/engine/SCons/compat/_scons_shlex.py', 'src/engine/SCons/compat/_scons_subprocess.py', - 'src/engine/SCons/compat/_scons_textwrap.py', 'src/engine/SCons/Conftest.py', 'src/engine/SCons/dblite.py', 'src/script/MANIFEST.in', @@ -263,12 +247,12 @@ for collector in check_list: if missing_strings: print "Found the following files with missing strings:" - print "\t" + string.join(missing_strings, "\n\t") + print "\t" + "\n\t".join(missing_strings) test.fail_test(1) if not_built: print "Cannot check all strings, the following have apparently not been built:" - print "\t" + string.join(not_built, "\n\t") + print "\t" + "\n\t".join(not_built) test.no_result(1) test.pass_test() -- cgit v1.2.3