Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/src/tools/Mutator.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ You can provide flags to `forge` as part of the `--test-cmd` parameter or target

`slither-mutate src/core/MyContract.sol --test-cmd='forge test --match-contract="MyContract"'`

If a `timout` flag is not provided, slither-mutate will default to using a value that's double the runtime of it's initial test cmd execution. Make sure you run `forge clean` or similar beforehand to ensure cache usage doesn't cause a timeout that's too short to be used; this could lead to false-negatives.

### CLI Interface

```shell
Expand All @@ -30,7 +32,7 @@ options:
--test-dir TEST_DIR Tests directory
--ignore-dirs IGNORE_DIRS
Directories to ignore
--timeout TIMEOUT Set timeout for test command (by default 30 seconds)
--timeout TIMEOUT Set timeout for test command (by default 2x the initial test runtime)
--output-dir OUTPUT_DIR
Name of output directory (by default 'mutation_campaign')
-v, --verbose log mutants that are caught, uncaught, and fail to compile
Expand Down
6 changes: 3 additions & 3 deletions slither/tools/mutator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too
if total_mutant_counts[0] > 0:
logger.info(
magenta(
f"Revert mutants: {uncaught_mutant_counts[0]} uncaught of {total_mutant_counts[0]} ({100 * uncaught_mutant_counts[0]/total_mutant_counts[0]}%)"
f"Revert mutants: {uncaught_mutant_counts[0]} uncaught of {total_mutant_counts[0]} ({round(100 * (total_mutant_counts[0] - uncaught_mutant_counts[0])/total_mutant_counts[0], 1)}% caught)"
)
)
else:
Expand All @@ -353,7 +353,7 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too
if total_mutant_counts[1] > 0:
logger.info(
magenta(
f"Comment mutants: {uncaught_mutant_counts[1]} uncaught of {total_mutant_counts[1]} ({100 * uncaught_mutant_counts[1]/total_mutant_counts[1]}%)"
f"Comment mutants: {uncaught_mutant_counts[1]} uncaught of {total_mutant_counts[1]} ({round(100 * (total_mutant_counts[1] - uncaught_mutant_counts[1])/total_mutant_counts[1], 1)}% caught)"
)
)
else:
Expand All @@ -362,7 +362,7 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too
if total_mutant_counts[2] > 0:
logger.info(
magenta(
f"Tweak mutants: {uncaught_mutant_counts[2]} uncaught of {total_mutant_counts[2]} ({100 * uncaught_mutant_counts[2]/total_mutant_counts[2]}%)\n"
f"Tweak mutants: {uncaught_mutant_counts[2]} uncaught of {total_mutant_counts[2]} ({round(100 * (total_mutant_counts[2] - uncaught_mutant_counts[2])/total_mutant_counts[2], 1)}% caught)\n"
)
)
else:
Expand Down
4 changes: 0 additions & 4 deletions slither/tools/mutator/utils/testing_generated_mutant.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ def run_test_cmd(
elif "hardhat test" in cmd or "truffle test" in cmd and "--bail" not in cmd:
cmd += " --bail"

if timeout is None and "hardhat" not in cmd: # hardhat doesn't support --force flag on tests
# if no timeout, ensure all contracts are recompiled w/out using any cache
cmd += " --force"

try:
result = subprocess.run(
cmd,
Expand Down