Open avylove opened 1 year ago
This sounds like a duplicate of #1514.
I fixed this in your repo with this patch:
diff --git a/tox.ini b/tox.ini
index 5620c78..ade7c05 100644
--- a/tox.ini
+++ b/tox.ini
@@ -218,6 +218,7 @@ commands =
[coverage:run]
branch = True
+data_file = .coverage-${TOX_ENV_NAME}
parallel = True
source =
blessed
Thanks, @nedbat!
It looks like a bunch of files get created in the .coverage-{TOX_ENV_NAME}.{HOSTNAME}.{PID}.{RANDOM}
format, but they get consolidated into the .coverage-{TOX_ENV_NAME}
files. So I guess the problem was these consolidated files were being consumed as pid-level files by other coverage processes in other Tox environments?
Since the pid-level files seem to be treated differently than the consolidated files, I wonder if it would be better if they had a different naming convention than the default data_file name?
I'm seeing one other issue after setting the data_file. coverage erase
won't remove any of the data files unless I specify --data-file
. And then, even if I use a wildcard, it only removes one.
I changed the line to:
data_file = .coverage.${TOX_ENV_NAME}
(dot instead of dash). Then I could combine all the files together with:
coverage combine --data-file=.coverage
I'm not sure how you have been combining the files up to now, perhaps you didn't need to because they were all using the same name, but that might mean you have been losing information.
Ah, I see now. The data_file name is used as a globing pattern for combine and erase. I'm sorry, it seems very obvious now.
I'm guessing you're right and we were missing coverage data locally, however we upload coverage files separately to codecov in CI and that doesn't seem to be affected.
Thanks for your help on this. I'm trying to think of a good way to address issues like this for others. Perhaps something in the docs for this use case and maybe a hint when the exception is raised. Something like:
This error is potentially caused by one of the following:
- The file was deleted by an external process
- Multiple instances of coverage are running in parallel using the same data_file name, see https://coverage.readthedocs.io/en/stable/parallel.html
- Aliens have abducted the file. They believe it to be ancient text describing the origin on the universe.
See also #1514.
Describe the bug When running with
tox --parallel auto
, files are missing or emptyTo Reproduce
Environment: Python 3.11.2 on Fedora 38, Tox 4.6.1 Tox is installing the latest coverage, 7.2.7
git clone https://github.com/jquast/blessed.git
cd blessed
tox --parallel auto -e py37,py38,py39,py310,py311,py312 -- --quiet
Pytest configuration (in tox.ini):
I'll get one of these two errors for several of the Tox environments
Expected behavior No errors
Additional context These tests spawn a lot of subprocesses, hundreds, if not thousands. I never have any issues running a single environment, but as soon as there are two, this issue is likely to surface. Seems like it could be a syncing issue.