[Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.35,1.36
Fred L. Drake
fdrake@users.sourceforge.net
Tue, 29 May 2001 10:10:53 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv6317
Modified Files:
regrtest.py
Log Message:
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.
Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -r1.35 -r1.36
*** regrtest.py 2001/05/22 18:28:25 1.35
--- regrtest.py 2001/05/29 17:10:51 1.36
***************
*** 231,235 ****
try:
if generate:
! cfp = open(outputfile, "w")
elif verbose:
cfp = sys.stdout
--- 231,235 ----
try:
if generate:
! cfp = StringIO.StringIO()
elif verbose:
cfp = sys.stdout
***************
*** 274,277 ****
--- 274,295 ----
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