Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: 🤝 hoist test subscriber into a standalone library #4200

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

cratelyn
Copy link
Contributor

in #4193, @zbuc is working on some changes to the dex component. in the penumbra-app crate, we have a helpful utility to define a tracing subscriber that correctly interacts with libtest's output capturing, and can be configured via RUST_LOG when running tests.

this is a tremendously helpful aid in debugging issues during feature development, and is not specific to the penumbra-app crate.

this commit hoists that test utility into a standalone library in crates/test/, so that other components like the dex can also create a guard to capture traces in tests.

now we can share this, by doing this:

 #[tokio::test]
 async fn example_test_case() -> anyhow::Result<()> {
     // Install a test logger...
     let guard = set_tracing_subscriber();

     // Test logic here...

     drop(guard);
     Ok(())
 }

checklist before requesting a review

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    only changes test code

in #4193, @zbuc is working on some changes to the dex component.
in the `penumbra-app` crate, we have a helpful utility to define a
tracing subscriber that correctly interacts with `libtest`'s output
capturing, and can be configured via `RUST_LOG` when running tests.

this is a tremendously helpful aid in debugging issues during feature
development, and is not specific to the `penumbra-app` crate.

this commit hoists that test utility into a standalone library in
`crates/test/`, so that other components like the dex can also create a
guard to capture traces in tests.

now we can share this, by doing this:

```rust
 #[tokio::test]
 async fn example_test_case() -> anyhow::Result<()> {
     // Install a test logger...
     let guard = set_tracing_subscriber();

     // Test logic here...

     drop(guard);
     Ok(())
 }
```
@cratelyn cratelyn added the A-testing Area: Relates to testing of Penumbra label Apr 12, 2024
@cratelyn cratelyn added this to the Sprint 4 milestone Apr 12, 2024
@cratelyn cratelyn requested a review from zbuc April 12, 2024 16:39
@cratelyn cratelyn self-assigned this Apr 12, 2024
@cratelyn cratelyn merged commit de66328 into main Apr 12, 2024
8 checks passed
@cratelyn cratelyn deleted the kate/hoist-tracing-subscriber-for-test-cases branch April 12, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing Area: Relates to testing of Penumbra
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants