This is a nice feature that I would definitely use.

On Mon, 15 Jul 2024 at 16:04, Bruno Oliveira <br...@soliv.dev> wrote:
>
> On Mon, Jul 15, 2024, at 9:53 AM, Florian Schulze wrote:
> >
> > What if the --lf option can optionally accept a file name, which when 
> > given, will read the set of failed tests from that file instead of reading 
> > it from the cache. This way you can just save the 
> > `.pytest_cache/lastfailed` file from CI, and reuse it locally:
> >
> >     pytest --lf=lastfailed-file-from-ci
> >
> > Seems like the changes would be minimal for that to happen.

I like this idea. I would want it to have behaviour that
--lf=failed.txt checks if the file exists and if not populates it with
the contents from the pytest ---lf cache. Then you could do:

$ pytest
< runts tests, some fail >
$ pytest --lf=failed=txt
< file doesn't exist so save last-failed there (from
.pytest_cache/last_failed) and run the failed tests >
$ pytest --lf=failed.txt
< file exists now so run tests specified in the file >

> I'm not sure how user-friendly it is to explain how to copy 
> ``.pytest_cache/lastfailed``, so I think ``--dump-lf`` would still be useful.

I think the behaviour for --lf=failed.txt I suggested is nicer than
expecting users to refer to this file directly.

> Seems just a matter of documenting to use the `upload-artifact` action to 
> upload the file unchanged, without users needing to worry about the contents 
> of the file.

Using upload-artifact is awkward for this. It would be nicer if you
could copy and paste the output from e.g. pytest -rA.

--
Oscar
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to