summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/linecount30
1 files changed, 22 insertions, 8 deletions
diff --git a/bin/linecount b/bin/linecount
index e344e2a..765309e 100644
--- a/bin/linecount
+++ b/bin/linecount
@@ -1,16 +1,23 @@
#!/usr/bin/env python
#
+# __COPYRIGHT__
+#
# Count statistics about SCons test and source files. This must be run
# against a fully-populated tree (for example, one that's been freshly
# checked out).
#
-# A test file is anything under the src/ directory that ends in
-# 'Tests.py', or anything under the test/ directory that ends in '.py'.
+# A test file is anything under the src/ directory that begins with
+# 'test_' or ends in 'Tests.py', or anything under the test/ directory
+# that ends in '.py'. Note that runtest.py script does *not*, by default,
+# consider the files that begin with 'test_' to be tests, because they're
+# tests of SCons packaging and installation, not functional tests of
+# SCons code.
#
# A source file is anything under the src/engine/ or src/script/
-# directories that ends in '.py' but does NOT end in 'Tests.py'. (We
-# should probably ignore the stuff in src/engine/SCons/Optik, since it
-# doesn't originate with SCons, but what the hell.)
+# directories that ends in '.py' but does NOT begin with 'test_'
+# or end in 'Tests.py'. (We should probably ignore the stuff in
+# src/engine/SCons/Optik, since it doesn't originate with SCons, but
+# what the hell.)
#
# We report the number of tests and sources, the total number of lines
# in each category, the number of non-blank lines, and the number of
@@ -18,24 +25,31 @@
# interesting one for most purposes.
#
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
import os.path
import string
tests = []
sources = []
+def is_test(x):
+ return x[:5] == 'test_' or x[-8:] == 'Tests.py'
+def is_python(x):
+ return x[-3:] == '.py'
+
def t(arg, dirname, names):
- names = filter(lambda n: n[-8:] == 'Tests.py', names)
+ names = filter(is_test, names)
arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names))
os.path.walk('src', t, tests)
def p(arg, dirname, names):
- names = filter(lambda n: n[-3:] == '.py', names)
+ names = filter(is_python, names)
arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names))
os.path.walk('test', p, tests)
def s(arg, dirname, names):
- names = filter(lambda n: n[-3:] == '.py' and n[-8:] != 'Tests.py', names)
+ names = filter(lambda n: is_python(n) and not is_test(n), names)
arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names))
os.path.walk('src/engine', s, sources)
os.path.walk('src/script', s, sources)