Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve some high-level help text & documentation #301

Merged
merged 1 commit into from
Jan 9, 2024
Merged
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
12 changes: 9 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ You can get started with a simple:

This will by default run pytest (or unittest if pytest is unavailable)
on tests in the "tests" or "test" folder and
it will try to figure out where the code to mutate lies. Run
it will try to figure out where the code to mutate lies.

NOTE that mutmut will apply the mutations directly, one at a time;
it is **highly** recommended to add all changes to source control
before running.

Enter

.. code-block:: console

mutmut --help
mutmut run --help

for the available flags, to use other runners, etc. The recommended way to use
mutmut if the defaults aren't working for you is to add a
Expand Down Expand Up @@ -96,11 +102,11 @@ grouped by file. You can now look at a specific mutant diff with ``mutmut show 3
all mutants for a specific file with ``mutmut show path/to/file.py`` or all mutants
with ``mutmut show all``.


You can also write a mutant to disk with ``mutmut apply 3``. You should **REALLY**
have the file you mutate under source code control and committed before you apply
a mutant!

To generate a HTML report for a web browser: ``mutmut html``

Whitelisting
------------
Expand Down
2 changes: 1 addition & 1 deletion mutmut/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ def compute_exit_code(
) -> int:
"""Compute an exit code for mutmut mutation testing

The following exit codes are available for mutmut:
The following exit codes are available for mutmut (as documented for the CLI run command):
* 0 if all mutants were killed (OK_KILLED)
* 1 if a fatal error occurred
* 2 if one or more mutants survived (BAD_SURVIVED)
Comment on lines +1289 to 1292
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this info would now be duplicated by the changes I proposed to the main run function, which I think is where this info belongs to be accessible to the user. I would be happy to trim down or remove the info here, if needed.

Expand Down
35 changes: 34 additions & 1 deletion mutmut/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ def do_apply(mutation_pk: str, dict_synonyms: List[str], backup: bool):
def climain():
"""
Mutation testing system for Python.

Getting started:

To run with pytest in test or tests folder: mutmut run

For more options: mutmut run --help

To show the results: mutmut results

To generate HTML report: mutmut html
"""
pass

Expand Down Expand Up @@ -128,6 +138,29 @@ def run(argument, paths_to_mutate, disable_mutation_types, enable_mutation_types
simple_output, no_progress, ci, rerun_all):
"""
Runs mutmut. You probably want to start with just trying this. If you supply a mutation ID mutmut will check just this mutant.

Runs pytest by default (or unittest if pytest is unavailable) on tests in the “tests” or “test” folder.

It is recommended to configure any non-default options needed in setup.cfg or pyproject.toml, as described in the documentation.

Exit codes:

* 0 - all mutants were killed

Otherwise any or sum of any of the following exit codes:

* 1 - if a fatal error occurred

* 2 - if one or more mutants survived

* 4 - if one or more mutants timed out

* 8 - if one or more mutants caused tests to take twice as long

(This is equivalent to a bit-OR combination of the exit codes that may apply.)

With --CI flag enabled, the exit code will always be
1 for a fatal error or 0 for any other case.
"""
if test_time_base is None: # click sets the default=0.0 to None
test_time_base = 0.0
Expand Down Expand Up @@ -255,7 +288,7 @@ def do_run(
) -> int:
"""return exit code, after performing an mutation test run.

:return: the exit code from executing the mutation tests
:return: the exit code from executing the mutation tests for run command
"""
if use_coverage and use_patch_file:
raise click.BadArgumentUsage("You can't combine --use-coverage and --use-patch")
Expand Down
Loading