summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-05-29 17:10:51 (GMT)
committerFred Drake <fdrake@acm.org>2001-05-29 17:10:51 (GMT)
commite51fe8d0a3d2a3fc83fd4f02521b0808c073bf50 (patch)
tree3bcd160bb0f1270bcf470ec455f9054b9f41689f /Lib
parent4f1e495fa0d134fca87f381b416e1759c9b4aa2b (diff)
downloadcpython-e51fe8d0a3d2a3fc83fd4f02521b0808c073bf50.zip
cpython-e51fe8d0a3d2a3fc83fd4f02521b0808c073bf50.tar.gz
cpython-e51fe8d0a3d2a3fc83fd4f02521b0808c073bf50.tar.bz2
runtest(): When generating output, if the result is a single line with the
name of the test, only write the output file if it already exists (and tell the user to consider removing it). This avoids the generation of unnecessary turds.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/regrtest.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 9c83221..4588036 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -230,7 +230,7 @@ def runtest(test, generate, verbose, quiet, testdir = None):
outputfile = os.path.join(outputdir, test)
try:
if generate:
- cfp = open(outputfile, "w")
+ cfp = StringIO.StringIO()
elif verbose:
cfp = sys.stdout
else:
@@ -273,6 +273,24 @@ def runtest(test, generate, verbose, quiet, testdir = None):
traceback.print_exc(file=sys.stdout)
return 0
else:
+ if generate:
+ output = cfp.getvalue()
+ if output == test + "\n":
+ if os.path.exists(outputfile):
+ # Write it since it already exists (and the contents
+ # may have changed), but let the user know it isn't
+ # needed:
+ fp = open(outputfile, "w")
+ fp.write(output)
+ fp.close()
+ print "output file", outputfile, \
+ "is no longer needed; consider removing it"
+ # else:
+ # We don't need it, so don't create it.
+ else:
+ fp = open(outputfile, "w")
+ fp.write(output)
+ fp.close()
return 1
def findtestdir():