run black reformatter

pull/2302/head
bohendo 9 months ago
parent e47f4e1b94
commit 924252e420
No known key found for this signature in database
  1. 36
      slither/tools/mutator/__main__.py
  2. 18
      slither/tools/mutator/mutators/abstract_mutator.py
  3. 1
      slither/tools/mutator/utils/file_handling.py
  4. 3
      slither/tools/mutator/utils/testing_generated_mutant.py

@ -212,10 +212,18 @@ def main() -> (None): # pylint: disable=too-many-statements,too-many-branches,t
else: else:
timeout = int(timeout) timeout = int(timeout)
if timeout < elapsed_time: if timeout < elapsed_time:
logger.info(red(f"Provided timeout {timeout} is too short for tests that run in {elapsed_time} seconds")) logger.info(
red(
f"Provided timeout {timeout} is too short for tests that run in {elapsed_time} seconds"
)
)
return return
logger.info(green(f"Test suite passes in {elapsed_time} seconds, commencing mutation campaign with a timeout of {timeout} seconds\n")) logger.info(
green(
f"Test suite passes in {elapsed_time} seconds, commencing mutation campaign with a timeout of {timeout} seconds\n"
)
)
for filename in sol_file_list: # pylint: disable=too-many-nested-blocks for filename in sol_file_list: # pylint: disable=too-many-nested-blocks
file_name = os.path.split(filename)[1].split(".sol")[0] file_name = os.path.split(filename)[1].split(".sol")[0]
@ -278,18 +286,34 @@ def main() -> (None): # pylint: disable=too-many-statements,too-many-branches,t
total_mutant_counts[0] += total_counts[0] total_mutant_counts[0] += total_counts[0]
uncaught_mutant_counts[0] += uncaught_counts[0] uncaught_mutant_counts[0] += uncaught_counts[0]
if verbose: if verbose:
logger.info(magenta(f"Mutator {m.NAME} found {uncaught_counts[0]} uncaught revert mutants (out of {total_counts[0]} that compile)")) logger.info(
magenta(
f"Mutator {m.NAME} found {uncaught_counts[0]} uncaught revert mutants (out of {total_counts[0]} that compile)"
)
)
elif m.NAME == "CR": elif m.NAME == "CR":
total_mutant_counts[1] += total_counts[1] total_mutant_counts[1] += total_counts[1]
uncaught_mutant_counts[1] += uncaught_counts[1] uncaught_mutant_counts[1] += uncaught_counts[1]
if verbose: if verbose:
logger.info(magenta(f"Mutator {m.NAME} found {uncaught_counts[1]} uncaught comment mutants (out of {total_counts[1]} that compile)")) logger.info(
magenta(
f"Mutator {m.NAME} found {uncaught_counts[1]} uncaught comment mutants (out of {total_counts[1]} that compile)"
)
)
else: else:
total_mutant_counts[2] += total_counts[2] total_mutant_counts[2] += total_counts[2]
uncaught_mutant_counts[2] += uncaught_counts[2] uncaught_mutant_counts[2] += uncaught_counts[2]
if verbose: if verbose:
logger.info(magenta(f"Mutator {m.NAME} found {uncaught_counts[2]} uncaught tweak mutants (out of {total_counts[2]} that compile)")) logger.info(
logger.info(magenta(f"Running total: found {uncaught_mutant_counts[2]} uncaught tweak mutants (out of {total_mutant_counts[2]} that compile)")) magenta(
f"Mutator {m.NAME} found {uncaught_counts[2]} uncaught tweak mutants (out of {total_counts[2]} that compile)"
)
)
logger.info(
magenta(
f"Running total: found {uncaught_mutant_counts[2]} uncaught tweak mutants (out of {total_mutant_counts[2]} that compile)"
)
)
dont_mutate_lines = lines_list dont_mutate_lines = lines_list
if comprehensive_flag: if comprehensive_flag:

@ -131,14 +131,16 @@ class AbstractMutator(
if self.very_verbose: if self.very_verbose:
if self.NAME == "RR": if self.NAME == "RR":
logger.info(f"Found {self.uncaught_mutant_counts[0]} uncaught revert mutants so far (out of {self.total_mutant_counts[0]} that compile)") logger.info(
f"Found {self.uncaught_mutant_counts[0]} uncaught revert mutants so far (out of {self.total_mutant_counts[0]} that compile)"
)
elif self.NAME == "CR": elif self.NAME == "CR":
logger.info(f"Found {self.uncaught_mutant_counts[1]} uncaught comment mutants so far (out of {self.total_mutant_counts[1]} that compile)") logger.info(
f"Found {self.uncaught_mutant_counts[1]} uncaught comment mutants so far (out of {self.total_mutant_counts[1]} that compile)"
)
else: else:
logger.info(f"Found {self.uncaught_mutant_counts[2]} uncaught tweak mutants so far (out of {self.total_mutant_counts[2]} that compile)") logger.info(
f"Found {self.uncaught_mutant_counts[2]} uncaught tweak mutants so far (out of {self.total_mutant_counts[2]} that compile)"
return (
self.total_mutant_counts,
self.uncaught_mutant_counts,
self.dont_mutate_line
) )
return (self.total_mutant_counts, self.uncaught_mutant_counts, self.dont_mutate_line)

@ -49,6 +49,7 @@ def transfer_and_delete(files_dict: Dict) -> None:
global_counter = {} global_counter = {}
def create_mutant_file(file: str, rule: str) -> None: def create_mutant_file(file: str, rule: str) -> None:
"""function to create new mutant file""" """function to create new mutant file"""
try: try:

@ -45,7 +45,7 @@ def run_test_cmd(cmd: str, timeout: int | None, target_file: str | None) -> bool
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
timeout=timeout, timeout=timeout,
check=False # True: Raises a CalledProcessError if the return code is non-zero check=False, # True: Raises a CalledProcessError if the return code is non-zero
) )
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
@ -68,6 +68,7 @@ def run_test_cmd(cmd: str, timeout: int | None, target_file: str | None) -> bool
return False return False
# return 0 if uncaught, 1 if caught, and 2 if compilation fails # return 0 if uncaught, 1 if caught, and 2 if compilation fails
def test_patch( # pylint: disable=too-many-arguments def test_patch( # pylint: disable=too-many-arguments
file: str, file: str,

Loading…
Cancel
Save