Esempio n. 1
0
 def generateEmmaReport(self, where, reportName, emmaReportType=EMMA_REPORT.HTML):
     emma = EmmaInterface(javaPath = self.config.getEmmaJavaPath(),
                          javaOpts = self.config.getEmmaJavaOpts(),
                          pathEmma = self.config.getEmmaDir(),
                          jarEmma = self.config.getEmmaJar(),
                          jarEmmaDevice = self.config.getEmmaDeviceJar())
     
     if not (self.metaFiles and self.reportFiles):
         raise ReportGenerationError("A metafile or a report file is absent.\
             Cannot generate report without one of these files!") 
     
     inputs = []
     inputs.extend(self.metaFiles)
     inputs.extend(self.reportFiles)
     
     #TODO: check the output
     emma.reportToDirWithName(inputs=inputs, toDir=where, mainFileName=reportName, report=emmaReportType)
Esempio n. 2
0
 def instrumentJarWithEmma(self, jarFile, outputFolder, emmaMetadataFile):
     '''
     Instruments provided jar file with Emma code coverage tool code. The
     resulting emmaMetadataFile is create with merge==yes, i.e., if the file
     exists the information about instrumentation will be merged with the 
     existing data. Only instrumented jar files will be copied to the
     outputFolder. 
     
     Args:
         :param jarFile: a jar file to instrument
         :param outputFolder: where to store instrumented file
         :param emmaMetadataFile: path to the file with emma instrumentation
             results
     '''
     ensureDirExists(outputFolder)
     emma = EmmaInterface(javaPath = self.config.getEmmaJavaPath(),
                          javaOpts = self.config.getEmmaJavaOpts(),
                          pathEmma = self.config.getEmmaDir(),
                          jarEmma = self.config.getEmmaJar(),
                          jarEmmaDevice = self.config.getEmmaDeviceJar())
     
     (successfulRun, cmdOutput) = emma.instr(instrpaths = [jarFile],
                                   outdir = outputFolder,
                                   emmaMetadataFile = emmaMetadataFile,
                                   merge = EMMA_MERGE.YES,
                                   outmode = EMMA_OUTMODE.FULLCOPY)
     if successfulRun:
         #emma put instrumented jar files into lib folder so we need to move
         #them back to the output folder and delete
         jarsOutDir = os.path.join(outputFolder, "lib")
         for filename in os.listdir(jarsOutDir):
             shutil.move(os.path.join(jarsOutDir, filename), os.path.join(outputFolder, filename))
         shutil.rmtree(jarsOutDir)
         return
     
     if not successfulRun:
         err = "Cannot instrument jar file [%s] with Emma. %s" % (jarFile, cmdOutput)
         raise EmmaCannotInstrumentException(err)