[gs-cvs] rev 7575 - trunk/gs/toolbin/tests

giles at ghostscript.com giles at ghostscript.com
Sat Jan 6 22:42:22 PST 2007


Author: giles
Date: 2007-01-06 22:42:22 -0800 (Sat, 06 Jan 2007)
New Revision: 7575

Modified:
   trunk/gs/toolbin/tests/gscheck_pdfwrite.py
   trunk/gs/toolbin/tests/gscheck_raster.py
   trunk/gs/toolbin/tests/gsconf.py
   trunk/gs/toolbin/tests/gstestutils.py
   trunk/gs/toolbin/tests/run_regression
   trunk/gs/toolbin/tests/testing.cfg.example
Log:
Changes to the regression tools to facilitate parallel runs.

DETAILS:

Add a scratchdir entry to testing.cfg to specify where temporary files
should be created instead of using the current working directory. 

Override various TextTestResult methods to print 'checking...result'
all at once instead of waiting while the job runs to reduce log 
mangling. The old behaviour was helpful behavior in an interactive 
serial run, but not running in batch mode.

If the PBS_NODENUM environment variable is set, use it to select a 
custom testing.cfg.

If PBS_NODENUM is set, only run the source tests when it is zero to
avoid duplicating these.


Modified: trunk/gs/toolbin/tests/gscheck_pdfwrite.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_pdfwrite.py	2007-01-06 20:35:32 UTC (rev 7574)
+++ trunk/gs/toolbin/tests/gscheck_pdfwrite.py	2007-01-07 06:42:22 UTC (rev 7575)
@@ -77,7 +77,7 @@
 
 	gs.device = 'pdfwrite'
         gs.dpi = None
-	gs.outfile = file1
+	gs.outfile = gsconf.scratchdir+file1
 	if not gs.process():
 	    self.fail("non-zero exit code trying to create pdf file from " + self.file)
 
@@ -85,17 +85,17 @@
 		
 	gs.device = self.device
         gs.dpi = self.dpi
-	gs.infile = file1
-	gs.outfile = file2
+	gs.infile = gsconf.scratchdir+file1
+	gs.outfile = gsconf.scratchdir+file2
 	if not gs.process():
 	    self.fail("non-zero exit code trying to"\
 		      " rasterize " + file1)
 
 	# compare baseline
 		
-	sum = gssum.make_sum(file2)
-	os.unlink(file1)
-	os.unlink(file2)
+	sum = gssum.make_sum(gsconf.scratchdir+file2)
+	os.unlink(gsconf.scratchdir+file1)
+	os.unlink(gsconf.scratchdir+file2)
 	
 	# add test result to daily database
 	if self.track_daily:

Modified: trunk/gs/toolbin/tests/gscheck_raster.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_raster.py	2007-01-06 20:35:32 UTC (rev 7574)
+++ trunk/gs/toolbin/tests/gscheck_raster.py	2007-01-07 06:42:22 UTC (rev 7575)
@@ -66,17 +66,17 @@
 	gs.dpi = self.dpi
 	gs.band = self.band
 	gs.infile = self.file
-	gs.outfile = file
+	gs.outfile = gsconf.scratchdir+file
 	if self.log_stdout:
 	    gs.log_stdout = self.log_stdout
 	if self.log_stderr:
 	    gs.log_stderr = self.log_stderr
 
 	if gs.process():
-	    sum = gssum.make_sum(file)
+	    sum = gssum.make_sum(gsconf.scratchdir+file)
         else:
 	    sum = ''
-	os.unlink(file)
+	os.unlink(gsconf.scratchdir+file)
 
 	# add test result to daily database
 	if self.track_daily:

Modified: trunk/gs/toolbin/tests/gsconf.py
===================================================================
--- trunk/gs/toolbin/tests/gsconf.py	2007-01-06 20:35:32 UTC (rev 7574)
+++ trunk/gs/toolbin/tests/gsconf.py	2007-01-07 06:42:22 UTC (rev 7575)
@@ -54,4 +54,11 @@
 def get_dailydb_name():
     return dailydir + time.strftime("%Y%m%d", time.localtime()) + ".db"
 
-parse_config()
+try:
+  # MPI version - node specific config
+  node=os.environ["PBS_NODENUM"]
+  parse_config(configdir+"testing.cfg."+node)
+except KeyError:
+  # normal version
+  parse_config()
+

Modified: trunk/gs/toolbin/tests/gstestutils.py
===================================================================
--- trunk/gs/toolbin/tests/gstestutils.py	2007-01-06 20:35:32 UTC (rev 7574)
+++ trunk/gs/toolbin/tests/gstestutils.py	2007-01-07 06:42:22 UTC (rev 7575)
@@ -132,13 +132,19 @@
 # Define a TestResult class that recognizes the GSTestFailure exception
 # as described above, and a TestRunner class that uses it.
 # The TestResult class also accepts a list or tuple of strings as the
-# error message.
+# error message, and prints the verbose log in a single line to
+# reduce mangling in parallel runs.
 
 class _GSTextTestResult(unittest._TextTestResult):
 
+    def startTest(self, test):
+	unittest.TestResult.startTest(self, test)
+
     def addFailure(self, test, err):
         self.failures.append((test, err))
         if self.showAll:
+	    self.stream.write(self.getDescription(test))
+	    self.stream.write(" ... ")
 	    lines = err[1].args[0]
 	    if (len(lines) > 18) & (lines[0:18] == "non-zero exit code"):
 		self.stream.writeln("ERROR")
@@ -146,7 +152,13 @@
 		self.stream.writeln("DIFFER")
         elif self.dots:
             self.stream.write("D")
-    
+
+    def addSuccess(self, test):
+	unittest.TestResult.addSuccess(self, test)
+	self.stream.write(self.getDescription(test))
+	self.stream.write(" ... ")
+	self.stream.writeln("ok")
+
     def printErrorList(self, flavor, errors):
         handoff = []
         for test, err in errors:

Modified: trunk/gs/toolbin/tests/run_regression
===================================================================
--- trunk/gs/toolbin/tests/run_regression	2007-01-06 20:35:32 UTC (rev 7574)
+++ trunk/gs/toolbin/tests/run_regression	2007-01-07 06:42:22 UTC (rev 7575)
@@ -23,7 +23,7 @@
 #
 # runs ghostscript regression tests
 
-import sys
+import os,sys
 import anydbm
 import gstestutils, gsconf
 import check_all
@@ -43,7 +43,15 @@
 gscheck_all.addTests(suite, gsroot=gsconf.gsroot, track=track)
 
 # Add tests not based on actually running Ghostscript.
-check_all.addTests(suite, gsroot=gsconf.gsroot)
+try:
+  # see if we're running a parallel job
+  node = int(os.environ["PBS_NODENUM"])
+except KeyError:
+  # always run
+  node = 0
+# run these tests only once in a parallel job
+if node == 0:
+  check_all.addTests(suite, gsroot=gsconf.gsroot)
 
 # run all the tests
 runner = gstestutils.GSTestRunner(verbosity=2)

Modified: trunk/gs/toolbin/tests/testing.cfg.example
===================================================================
--- trunk/gs/toolbin/tests/testing.cfg.example	2007-01-06 20:35:32 UTC (rev 7574)
+++ trunk/gs/toolbin/tests/testing.cfg.example	2007-01-07 06:42:22 UTC (rev 7575)
@@ -5,6 +5,7 @@
 crashfiledir	/home/regression/crashfiles/
 codedir		/home/regression/regression/
 datadir		/home/regression/regression/
+scratchdir	/home/regression/regression/
 logdir		/home/regression/regression/logs/
 dailydir	/home/regression/regression/daily/
 rasterdbdir	/home/regression/regression/raster/



More information about the gs-cvs mailing list