mutmut: Exit 1 with "FAILED" and no explanation after forced fail test

I thought it might be because I have skipped a few tests for now because they don’t play ball when running with mutmut, but I commented them out and the result was the same.

Should this line be…

if runner.run_forced_fail() != 0

It’s not obvious to me what the purpose or expected behaviour of the forced failed run is and it doesn’t seem to be mentioned in the documentation.

I don’t think our code resets os.environ anywhere.

Steps to replicate

# Setup
git clone git@github.com:uktrade/platform-tools.git
git checkout 3562d91
poetry install

# Run
rm -rf mutants # In case you already have stuff in the mutants directory
poetry run mutmut run

Expected behaviour

Mutations are tested

Actual behaviour

Exit code: 1 ➜ rm -rf mutants && poetry run mutmut run
...
Running forced fail test
...
=== 609 passed, 4 skipped in 23.40s ===
    exit code 0
FAILED
Exit code: 1 ➜ 

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 21 (17 by maintainers)

Most upvoted comments

I would like to get to the bottom of it. So that we can use Mutmut 3, which as you say is fast, and to help make it easier for others to start using it.

Forced fail is a quick check to see if the mutants are being run. It’s quite easy to get into a situation where the original code is first in the import list and then all mutants will survive. Which might be what happens in your case. During forced fail, ideally only one test should be run and that should immediately fail.