Show
Ignore:
Timestamp:
12/09/07 12:05:14 (17 years ago)
Author:
jerome
Message:

More informations in the testsuite.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/tests/gstests.py

    r537 r544  
    150150                                        'gs -dBATCH -dQUIET -dPARANOIDSAFER -dNOPAUSE -sDEVICE=ijs -sIjsServer=hpijs -dIjsUseOutputFD -sDeviceManufacturer="HEWLETT-PACKARD" -sDeviceModel="%(device)s" -sOutputFile="%(outfilename)s" "%(infilename)s"') 
    151151                 
     152    def runPipe(self, cmd) :             
     153        """Runs a command in a pipe, returns the command's output as a string.""" 
     154        answerfd = os.popen(cmd, "r") 
     155        try : 
     156            return answerfd.read().strip() 
     157        finally :         
     158            answerfd.close() 
     159         
    152160    def computeSize(self, filename) :     
    153161        """Computes the size in pages of a file in the testsuite.""" 
    154         answerfd = os.popen('pkpgcounter "%(filename)s" 2>/dev/null' % locals(), "r") 
     162        answer = self.runPipe('pkpgcounter "%(filename)s" 2>/dev/null' % locals()) 
    155163        try : 
    156             try : 
    157                 return int(answerfd.readline().strip()) 
    158             except (ValueError, TypeError) :     
    159                 return 0 
    160         finally :         
    161             answerfd.close() 
     164            return int(answer) 
     165        except (ValueError, TypeError) :     
     166            return 0 
    162167         
    163168    def runTests(self) : 
     
    203208        """Generates an HTML report.""" 
    204209        reportdate = "%s (UTC)" % time.asctime(time.gmtime(time.time())) 
    205         title = "pkpgcounter report for testsuite %s generated on %s" % (self.md5sum, reportdate) 
     210        title = "pkpgcounter v%s report for testsuite %s generated on %s" \ 
     211                        % (self.runPipe("pkpgcounter --version"), \ 
     212                           self.md5sum, \ 
     213                           reportdate) 
    206214        out = open(filename, "w") 
    207215        out.write("<html><head><title>%s</title></head><body>\n" % title) 
     
    210218        out.write("<li>Testsuite's MD5 checksum : <strong>%s</strong></li>\n" % self.md5sum) 
    211219        out.write("<li>Testsuite contains : <strong>%i pages</strong></li>\n" % self.mastersize) 
     220        out.write("<li>Ghostscript used to generate testsuite : <strong>v%s</strong></li>\n" % self.runPipe("gs --version")) 
    212221        out.write("<li>Supported : <strong>%.2f%%</strong></li>\n" % self.supportedpct) 
    213222        out.write("<li>Failed : <strong>%.2f%%</strong></li>\n" % self.failedpct) 
    214223        out.write("<li>Unsupported : <strong>%.2f%%</strong></li>\n" % self.unsupportedpct) 
    215224        out.write("</ul>\n") 
    216         out.write("<p><strong>Green</strong> means that pkpgcounter obtained the expected result</p>\n") 
    217         out.write("<p><strong>Orange</strong> means that pkpgcounter obtained an incorrect result</p>\n") 
    218         out.write("<p><strong>Red</strong> means that pkpgcounter doesn't recognize the input file's format</p>\n") 
     225        out.write("<p><strong>Green</strong> means that pkpgcounter obtained the expected result.</p>\n") 
     226        out.write("<p><strong>Orange</strong> means that pkpgcounter obtained an incorrect result.<em>IMPORTANT : if only 1 page is found, this is often due to image formats which don't support multiple pages anyway.</em></p>\n") 
     227        out.write("<p><strong>Red</strong> means that pkpgcounter doesn't recognize the input file's format.</p>\n") 
    219228        out.write('<table border="1"><tr bgcolor="gold"><th width="15%">Device</th><th width="25%">Details</th><th width="60%">Command line</th></tr>\n') 
    220229        linecount = 0