async-rs / async-rs/async-attributes

Figure out a way to support checking #[async_attributes::test] in doctests

Open
#22 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
49
Forks
12
PR merge metrics
No merged PRs in 30d

Description

It would be very valuable for documenting test utils to have `cargo check` be able to run on `#[async_attributes::test]` function in doctests.

For example, the obvious errors here would have been caught, as it clearly can't compile: https://github.com/eaze/preroll/blob/c0d15ef0692ef8f933d3501a708f38f0acd69c9a/src/test_utils/mod.rs#L42-L53 (Wrong naming of `create_app`.)

Unfortunately, `cfg(doctest) seems like it broken and there perhaps is no obvious (or certainly easy) way to fix it, and doesn't seem to be garnering any action: https://github.com/rust-lang/rust/issues/67295

I suggest we find some (even if convoluted) way to run these in doc tests, even if by a manual feature flag.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing how cargo check handles #[async_attributes::test] in doctests, then read the cfg(doctest) discussion in Rust issue #67295. Use the example in src/test_utils/mod.rs as the motivating case and assess a manual feature flag or other route. Done means doctest functions using the attribute are checked and obvious errors such as the wrong create_app name are reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.