class Mutator: """ Generates all possible combinations of mutants. """ def __init__(self, project): self.project = project self.store = FileStore("mutants") def mutate(self): """ Performs the mutation. Applies mutation operator to each source file, then stores a diff between the original and mutated file. # mutants = # source files x # mutation operators """ count = 0 start = time() for src_file in self.project.source_files(): original_path = join(self.project.settings["source_path"], src_file) mutant_path = join(out_dir, src_file) mkdir_p(dirname(mutant_path)) for (op, invoke) in self.project.settings["mutants"].items(): if invoke: p = Popen(["txl", original_path, join("vendor", "conman", "%s.Txl" % op)], stdout=open(mutant_path, "w"), stderr=open("/dev/null")) self.store.put(diff(relpath(original_path), relpath(mutant_path)), op, src_file) count += 1 if count % 1000 == 0: print("Generated %d mutants. Elapsed time %.02f seconds." % (count, (time() - start))) stop = time() print("Generated %d mutants in %d seconds." % (count, (stop - start)))
class Mutator: """ Generates all possible combinations of mutants. """ def __init__(self, project): self.project = project self.store = FileStore("mutants") def mutate(self): """ Performs the mutation. Applies mutation operator to each source file, then stores a diff between the original and mutated file. # mutants = # source files x # mutation operators """ count = 0 start = time() for src_file in self.project.source_files(): original_path = join(self.project.settings["source_path"], src_file) mutant_path = join(out_dir, src_file) mkdir_p(dirname(mutant_path)) for (op, invoke) in self.project.settings["mutants"].items(): if invoke: p = Popen([ "txl", original_path, join("vendor", "conman", "%s.Txl" % op) ], stdout=open(mutant_path, "w"), stderr=open("/dev/null")) self.store.put( diff(relpath(original_path), relpath(mutant_path)), op, src_file) count += 1 if count % 1000 == 0: print( "Generated %d mutants. Elapsed time %.02f seconds." % (count, (time() - start))) stop = time() print("Generated %d mutants in %d seconds." % (count, (stop - start)))
def createStore(self): if super(StoreFactory, self).createStore() is not None: return super(StoreFactory, self).createStore() pp = self.propertiesImporter() # increase readability a bit # No other store set up. Grab the configuration, check for postgres. root = pp.getRDFUtil().getRoot() storeConfig = root.getThing(predicate=VV.HAS_STORE) if (storeConfig.isA(VV.POSTGRES_STORE_TYPE)): from PGTransactionStore import PGTransactionStore self.store(newStore=PGTransactionStore( dbprops=pp.getDatabaseProperties(storeConfig=storeConfig))) elif storeConfig.isA(VV.FILE_STORE_TYPE): self.store( newStore=FileStore(storeConfig.getString(VV.FILE_DATA_PATH), storeConfig.getString(VV.FILE_INDEX_PATH))) elif storeConfig.isA(VV.MEMORY_STORE_TYPE): self.store(newStore=MemoryStore()) else: raise Exception('ERROR no store found!') return self.store()
def __init__(self, project): self.project = project self.store = FileStore("mutants")
def __set_storage(): if STORAGE_TYPE == 'mongo': return MongoStore() return FileStore()