insta icon indicating copy to clipboard operation
insta copied to clipboard

Allow passing args through to test binary with nextest

Open max-sixty opened this issue 4 months ago • 4 comments

Pass args to nextest and test binary with two -- — every after the first -- goes to nextest, and nextest passes everything after the second -- to the test binary.

For example, cargo insta test -- --status-level fail -- --nocapture

Currently it maintains backward compat -- a single -- will pass to the test binary only, with a depreciation warning. eventually that'll pass them to nextest only.

(for transparency, Claude Code helped with the code)

max-sixty avatar Aug 30 '25 01:08 max-sixty

Thanks for working on this! I'm not sure the double -- would make the best user experience though. Maybe it would be better to copy the relevant nextest options in cargo insta test? Or add a --test-runner-options?

glehmann avatar Aug 30 '25 12:08 glehmann

Or add a --test-runner-options?

I considered this. but then would --test-runner-options="--status-level fail -- --nocapture" give the same result as cargo insta test -- --status-level fail -- --nocapture would in the proposed code?

(and then less keen on adding options to insta to track all of nextest's)

max-sixty avatar Aug 30 '25 13:08 max-sixty

Or add a --test-runner-options?

I considered this. but then would --test-runner-options="--status-level fail -- --nocapture" give the same result as cargo insta test -- --status-level fail -- --nocapture would in the proposed code?

I was thinking of cargo insta --test-runner nextest --test-runner-options="--status-level=fail" -- --no-capture, which continues to use -- as currently.

But both examples you're showing are good enough IMO. I would be more uncomfortable with cargo insta test -- -- --no-capture. That's a lot of --!

Anyway, that's probably a matter of taste. In the end, any solution would work for me :+1:

glehmann avatar Aug 30 '25 15:08 glehmann

on reflection, this code is overly complicated and would be much simpler if we didn't run doctests separately. so I got around to doing https://github.com/mitsuhiko/insta/pull/803, and we can merge a version of this when we've removed the supplemental doctest run

max-sixty avatar Sep 09 '25 19:09 max-sixty