mutmut
mutmut copied to clipboard
Running `mutmut show <id>` causes a parallel `mutmut run` to traceback
The nature of mutmut
is that the tests will take a fair amount of time to complete. I would like to be able to start looking at the surviving mutations before they have all been tested, but currently running mutmut show N
will cause this traceback in the mutmut run
command:
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/mutmut/__main__.py", line 426, in main
run_mutation_tests(config=config, mutations_by_file=mutations_by_file)
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/mutmut/__main__.py", line 624, in run_mutation_tests
run_mutation_tests_for_file(config, file_to_mutate, mutations)
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/mutmut/__main__.py", line 611, in run_mutation_tests_for_file
update_mutant_status(file_to_mutate, mutation_id, status, config.hash_of_tests)
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/mutmut/cache.py", line 105, in wrapper
return f(*args, **kwargs)
File "<string>", line 2, in update_mutant_status
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/pony/orm/core.py", line 528, in new_func
result = func(*args, **kwargs)
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/mutmut/cache.py", line 302, in update_mutant_status
mutant = Mutant.get(line=line, index=mutation_id.index)
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/pony/orm/core.py", line 3955, in get
try: return entity._find_one_(kwargs) # can throw MultipleObjectsFoundError
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/pony/orm/core.py", line 4049, in _find_one_
avdict[attr] = attr.validate(val, None, entity, from_db=False)
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/pony/orm/core.py", line 2519, in validate
attr if obj is None or obj._status_ is None else '%r.%s' % (obj, attr.name)))
File "/home/daniel/.virtualenvs/jenkins-job-linter/lib/python3.7/site-packages/pony/utils/utils.py", line 106, in throw
raise exc
ValueError: Attribute Mutant.line is required
This reproduces fairly reliably on https://github.com/OddBloke/jenkins-job-linter.
Ah crap. This is immediately obvious to me what's going on. The mutant statuses shouldn't be updated if mutmut is currently running. I didn't think about this when fixing another bug. I guess we need some kind of lock or something...
A process-level lock would avoid this traceback (and replace it with an error message, presumably), which would be an improvement. It would be good, though, to consider if the locking could be more fine grained so that I would still be able to see the results/mutations whilst a run
is happening.