Skip to content

Commit

Permalink
consolidate & clean verbose & very_verbose logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Jan 9, 2025
1 parent ab28eb1 commit 9ea7329
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
16 changes: 0 additions & 16 deletions slither/tools/mutator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ def parse_args() -> argparse.Namespace:
default=False,
)

# to print just all the mutants
parser.add_argument(
"-vv",
"--very-verbose",
help="log mutants that are caught, uncaught, and fail to compile. And more!",
action="store_true",
default=False,
)

# select list of mutators to run
parser.add_argument(
"--mutators-to-run",
Expand Down Expand Up @@ -159,15 +150,11 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too
timeout: Optional[int] = args.timeout
solc_remappings: Optional[str] = args.solc_remaps
verbose: Optional[bool] = args.verbose
very_verbose: Optional[bool] = args.very_verbose
mutators_to_run: Optional[List[str]] = args.mutators_to_run
comprehensive_flag: Optional[bool] = args.comprehensive

logger.info(blue(f"Starting mutation campaign in {args.codebase}"))

if very_verbose: # very_verbose should always be a superset of verbose logs
verbose = True

if paths_to_ignore:
paths_to_ignore_list = paths_to_ignore.strip("][").split(",")
else:
Expand Down Expand Up @@ -293,7 +280,6 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too
target_contract,
solc_remappings,
verbose,
very_verbose,
output_folder,
dont_mutate_lines,
)
Expand Down Expand Up @@ -378,8 +364,6 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too
logger.info(magenta("Zero Tweak mutants analyzed\n"))

# Reset mutant counts before moving on to the next file
if very_verbose:
logger.info(blue("Reseting mutant counts to zero"))
total_mutant_counts[0] = 0
total_mutant_counts[1] = 0
total_mutant_counts[2] = 0
Expand Down
17 changes: 0 additions & 17 deletions slither/tools/mutator/mutators/abstract_mutator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__( # pylint: disable=too-many-arguments
contract_instance: Contract,
solc_remappings: Union[str, None],
verbose: bool,
very_verbose: bool,
output_folder: Path,
dont_mutate_line: List[int],
rate: int = 10,
Expand All @@ -44,7 +43,6 @@ def __init__( # pylint: disable=too-many-arguments
self.timeout = timeout
self.solc_remappings = solc_remappings
self.verbose = verbose
self.very_verbose = very_verbose
self.output_folder = output_folder
self.contract = contract_instance
self.in_file = self.contract.source_mapping.filename.absolute
Expand Down Expand Up @@ -98,7 +96,6 @@ def mutate(self) -> Tuple[List[int], List[int], List[int]]:
self.timeout,
self.solc_remappings,
self.verbose,
self.very_verbose,
)

# count the uncaught mutants, flag RR/CR mutants to skip further mutations
Expand Down Expand Up @@ -132,18 +129,4 @@ def mutate(self) -> Tuple[List[int], List[int], List[int]]:
else:
self.total_mutant_counts[2] += 1

if self.very_verbose:
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)"
)
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)"
)
else:
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
3 changes: 1 addition & 2 deletions slither/tools/mutator/utils/testing_generated_mutant.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def test_patch( # pylint: disable=too-many-arguments
timeout: int,
mappings: Union[str, None],
verbose: bool,
very_verbose: bool,
) -> int:
"""
function to verify whether each patch is caught by tests
Expand All @@ -118,7 +117,7 @@ def test_patch( # pylint: disable=too-many-arguments

return 0 # uncaught
else:
if very_verbose:
if verbose:
logger.info(
yellow(
f"[{generator_name}] Line {patch['line_number']}: '{patch['old_string']}' ==> '{patch['new_string']}' --> COMPILATION FAILURE"
Expand Down

0 comments on commit 9ea7329

Please sign in to comment.