-
Notifications
You must be signed in to change notification settings - Fork 114
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 error message when forced fail test fails #354
base: main
Are you sure you want to change the base?
Changes from 1 commit
13139ec
587f7d3
70cbf80
c08280d
615f592
2c3113d
85191f2
5c60640
7d7c8b9
4d3050a
66b3705
030faa8
ab66e9e
6fd2e3b
f94b649
5777f87
009f55b
712d279
c2f57ab
7faadf9
d5de126
c6ce598
134d502
bb002bc
de1020d
39a748f
3084a76
29add96
713e228
8f8c2cd
ac19491
a7ca7d0
43a4bdd
a94e680
af2663a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -885,14 +885,14 @@ def print_stats(source_file_mutation_data_by_path, force_output=False): | |
print_status(f'{(s.total - s.not_checked)}/{s.total} 🎉 {s.killed} 🫥 {s.no_tests} ⏰ {s.timeout} 🤔 {s.suspicious} 🙁 {s.survived} 🔇 {s.skipped}', force_output=force_output) | ||
|
||
|
||
def run_forced_fail(runner): | ||
def run_forced_fail_test(runner): | ||
os.environ['MUTANT_UNDER_TEST'] = 'fail' | ||
with CatchOutput(spinner_title='Running forced fail test') as catcher: | ||
try: | ||
if runner.run_forced_fail() == 0: | ||
catcher.dump_output() | ||
print("FAILED") | ||
os._exit(1) | ||
print("Error: Unable to force a test failure during the forced fail test") | ||
raise SystemExit(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest "FAILED: Unable to force test failures". To be consistent, and for brevity. Why did you change the exit? I use os._exit() for fast exit, so we don't spend time deallocating at the end of the process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have update the error message. I switched to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the unit tests I added are failing in GitHub Actions because the output emitted by I have tried adding some sleeps to rule out a race condition and changing the runner to MacOS in case that was a factor. No banana. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @boxed I have poked around and set things up so that there is a test that does not capture the output and running single tests with verbose etc. If you look at this GitHub Action run, it seems that CatchOutput is only capturing the first line of the output in GitHub Actions for some reason. You can see "done" (and "FAILED" for come reason without the new text) in the test output. My time for playing this morning has run out. If you have any thoughts on why this might be I would be interested in hearing them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temporarily running the tests on MacOS as well as Ubuntu in GitHub Actions indicates it's not an OS difference. I'm now wondering whether there is some difference in the way https://github.com/actions/setup-python installs Python compared to how I installed it (via asdf) on my laptop. @boxed (or anyone else) If you checkout this branch and run the following, does it pass or fail, and how did you install Python?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It passes. I use basic venv and pip. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. But... damn. I wonder what the difference is in GitHub Actions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I comment out the I suspect @boxed What is the intent/purpose of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea that makes sense. The purpose is to not show a lot of output when running mutmut, but being able to dump it on errors. Showing all output to the user would make the tool basically unusable. |
||
except MutmutProgrammaticFailException: | ||
pass | ||
os.environ['MUTANT_UNDER_TEST'] = '' | ||
|
@@ -1254,7 +1254,7 @@ def run(mutant_names, *, max_children): | |
print(' done') | ||
|
||
# this can't be the first thing, because it can fail deep inside pytest/django setup and then everything is destroyed | ||
run_forced_fail(runner) | ||
run_forced_fail_test(runner) | ||
|
||
runner.prepare_main_test_run() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to better differentiate it from the
runner
'srun_force_fail
method.