summaryrefslogtreecommitdiff
path: root/runtest.py
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 +0000
committerGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 +0000
commiteb7e67b1e6e7315a945edf79ebd2ec160ee85588 (patch)
treefff879b4f9676a72e16c0f7b4dd969f050038b4f /runtest.py
parentd5d9fceff1591065e13c1fcd283468fb0a288a36 (diff)
downloadscons-eb7e67b1e6e7315a945edf79ebd2ec160ee85588.tar.gz
http://scons.tigris.org/issues/show_bug.cgi?id=2329
Applied a number of idiomatic changes. Uses of the 'sort()' method were converted into calls of 'sorted()' when possible and the sorted() expression was inserted into a subsequent statement whenever that made sense. The statement 'while 1:' was changed to 'while True:'. Names from the 'types' module (e.g., 'types.FooType') were converted to the equivalent build-in type (e.g., 'foo'). Comparisons between types were changed to use 'isinstance()'.
Diffstat (limited to 'runtest.py')
-rw-r--r--runtest.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/runtest.py b/runtest.py
index 7fb505a3..11f87e1a 100644
--- a/runtest.py
+++ b/runtest.py
@@ -97,6 +97,31 @@ import time
if not hasattr(os, 'WEXITSTATUS'):
os.WEXITSTATUS = lambda x: x
+try:
+ sorted
+except NameError:
+ # Pre-2.4 Python has no sorted() function.
+ #
+ # The pre-2.4 Python list.sort() method does not support
+ # list.sort(key=) nor list.sort(reverse=) keyword arguments, so
+ # we must implement the functionality of those keyword arguments
+ # by hand instead of passing them to list.sort().
+ def sorted(iterable, cmp=None, key=None, reverse=0):
+ if key is not None:
+ result = [(key(x), x) for x in iterable]
+ else:
+ result = iterable[:]
+ if cmp is None:
+ # Pre-2.3 Python does not support list.sort(None).
+ result.sort()
+ else:
+ result.sort(cmp)
+ if key is not None:
+ result = [t1 for t0,t1 in result]
+ if reverse:
+ result.reverse()
+ return result
+
cwd = os.getcwd()
all = 0
@@ -619,9 +644,7 @@ if args:
os.path.walk(path, find_Tests_py, tdict)
elif path[:4] == 'test':
os.path.walk(path, find_py, tdict)
- t = tdict.keys()
- t.sort()
- tests.extend(t)
+ tests.extend(sorted(tdict.keys()))
else:
tests.append(path)
elif testlistfile:
@@ -658,8 +681,7 @@ elif all and not qmtest:
elif a[-1] not in tdict:
tdict[a[-1]] = Test(a[-1], spe)
- tests = tdict.keys()
- tests.sort()
+ tests = sorted(tdict.keys())
if qmtest:
if baseline: