Test functions should work when defined inside other functions
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Issue by brson
Wednesday Sep 19, 2012 at 01:12 GMT
For earlier discussion, see https://github.com/rust-lang/rust/issues/3532
This issue was labelled with: A-frontend, A-testsuite, E-hard, I-wishlist in the Rust repository
This doesn't work, but I frequently want to do it
fn foo() {
...
#[test]
fn test1() { }
}
The generated code for running test functions uses paths to the tests, and it's not possible to generate a path to test1. The test runner already breaks resolution rules to run private tests, so maybe we can break yet more.
We would want to consider though how this could work with reflection-based test runners - the way we currently break visibility rules to run tests is already bad news for reflection.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the earlier discussion in issue 3532, then examine how generated test-running code resolves paths to test functions and how the test runner handles private tests. The change would need nested #[test] functions such as test1 to run while accounting for the stated visibility and reflection-based runner concerns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100