tracing-test icon indicating copy to clipboard operation
tracing-test copied to clipboard

Integration tests should see trace from the main crate by default

Open sourcefrog opened this issue 3 years ago • 3 comments

I think it would be nice to somehow make the default for integration tests be that it sees trace from the crate under test but not others. It seems like it should be possible, but perhaps it's complicated.

Originally posted by @sourcefrog in https://github.com/dbrgn/tracing-test/issues/20#issuecomment-1410521124

I haven't looked at the implementation yet, but it seems like this ought to be possible?

  • determine the name of the main crate for the package
  • set a filter accordingly

This would be a nicer default experience and also allow seeing logs from the crate under test but not its dependencies.

sourcefrog avatar Feb 03 '23 03:02 sourcefrog

I haven't yet investigated this issue. Do you know a way to do this reliably?

determine the name of the main crate for the package

If yes, then it should be quite easy to set the filter appropriately.

dbrgn avatar Feb 05 '23 11:02 dbrgn

One way to do it would be to look at https://docs.rs/cargo_metadata/ output, but there might be simpler ways...

sourcefrog avatar Feb 06 '23 14:02 sourcefrog

Failing this, would it be possible to make the filter more configurable than no-env-filter? Even if I need to manually supply (as a macro argument?) the name of the crate(s) I want to get trace-level logs for, it would make the traced test output far more usable than it is currently for integration tests.

AloeareV avatar Nov 27 '23 00:11 AloeareV