Skip to content

Test runner needs to be able to run unexported tests #721

Closed
@brson

Description

@brson

Currently, tests have to be visible at the top level of the crate to be run, observing the normal rules for item visibility. In Rust we can have layers and layers of unexported modules - modules that still need to be tested. There are a few ways to allow these to be tested:

  • With reexporting we could require the user to bubble up their tests to the top level
  • With reexporting we could possibly have the test runner fold generate exports to do the same
  • We could cheat, which is what I want to do

The test runner generates a method that looks like this

__tests() -> test_desc[] {
   ... build a vector of test functions ...
}

I want to add a secret attribute to __tests, #[__resolve_unexported], that tells the resolve pass to follow paths regardless of whether the item is exported, allowing this one function to look into the bowels of the crate.

To prevent abuse we could even give the attribute an unparsable ident, like #[!resolve_unexported]

Metadata

Metadata

Assignees

Labels

A-testsuiteArea: The testsuite used to check the correctness of rustc

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions