Skip to content

Discover tests using a custom test harness #21259

@MichaReiser

Description

@MichaReiser

First, thank you for your hard work on rust-analyzer.

We consider migrating from dirtest to datatest-stable. dir-test exports a macro that generates a #[test] function for every file in a given directory. This is great because it plays really nicely with r-a: r-a detects the tests and we can run them by name. However, it has the downside that it requires a build.rs file that invalidates the macro whenever one of our spec files change, which leads to very slow iteration cycles.

That's why we consider migrating to datatest-stable. It uses a custom test harness that mimics cargo test. This is great because it removes the need for the build.rs file and the need to recompile the tests after making changes to the spec files. However, we lose the r-a integration because the tests are now no longer expanded in a macro.

Supporting this use case is tricky because r-a can't make any assumptions about a custom test harness. One possible solution would be to support fetching the known tests using cargo test -- --list (ideally with a custom filter). Obviously, it would fail to automatically detect new tests but that's already the case with our existing dirtest setup where it's necessary to manually clear the macro-cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-featureCategory: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions