How to use the universalmutator.mutator.makeMutant function in universalmutator

To help you get started, we’ve selected a few universalmutator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github agroce / universalmutator / universalmutator / genmutants.py View on Github external
mutantResult = handler(tmpMutantName, mutant, sourceFile, uniqueMutants)
            else:
                mutantResult = handler(tmpMutantName, mutant, sourceFile, uniqueMutants, compileFile=compileFile)
            if mutantResult in ["VALID", "REDUNDANT"]:
                deadCodeLines.append(mutant[0])
                print("LINE", str(mutant[0]) + ":", source[mutant[0] - 1][:-1], end=" ")
                print("APPEARS TO BE COMMENT OR DEAD CODE, SKIPPING...")
            else:
                interestingLines.append(mutant[0])
        if mutant[0] in deadCodeLines:
            continue
        print("PROCESSING MUTANT:",
              str(mutant[0]) + ":", source[mutant[0] - 1][:-1], " ==> ", mutant[1][:-1], end="...")
        if showRules:
            print("(FROM:", mutant[2][1], end=")...")
        mutator.makeMutant(source, mutant, tmpMutantName)
        if compileFile is None:
            mutantResult = handler(tmpMutantName, mutant, sourceFile, uniqueMutants)
        else:
            mutantResult = handler(tmpMutantName, mutant, sourceFile, uniqueMutants, compileFile=compileFile)
        print(mutantResult, end=" ")
        mutantName = mdir + base + ".mutant." + str(mutantNo) + ending
        if (mutantResult == "VALID") or (mutantResult == "REDUNDANT" and redundantOK):
            print("[written to", mutantName + "]", end=" ")
            shutil.copy(tmpMutantName, mutantName)
            validMutants.append(mutant)
            mutantNo += 1
        elif mutantResult == "INVALID":
            invalidMutants.append(mutant)
        elif mutantResult == "REDUNDANT":
            redundantMutants.append(mutant)
        print()