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

#[test] items are not being configured out in a non-test build #1126

Closed
marijnh opened this issue Nov 4, 2011 · 6 comments
Closed

#[test] items are not being configured out in a non-test build #1126

marijnh opened this issue Nov 4, 2011 · 6 comments
Assignees
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc

Comments

@marijnh
Copy link
Contributor

marijnh commented Nov 4, 2011

They probably should. They could refer to things configured with #[cfg(test)], and will cause resolve errors when those are configured out.

@brson
Copy link
Contributor

brson commented Nov 4, 2011

It's probably intuitive to do this, but there are two reasons I didn't implement it.

  1. There's already a mechanism for this (cfg attributes)
  2. I can imagine a situation where you would want to both compile in the tests and not compile the crate as a test-runner. For example, an application might want to be able to run its own tests for diagnostic purposes.

@marijnh
Copy link
Contributor Author

marijnh commented Nov 4, 2011

Right, but writing #[test]#[cfg(test)] seems awkwardly redundant. For 2), which seems rare to me, it would be trivial to factor the tests into a non-#[test] function and call them both from a #[test] function and from some other part of the program.

@brson
Copy link
Contributor

brson commented Nov 4, 2011

This is why all of the tests in rustc live in #[cfg(test) mod test { ... }. As it stands, for 2 you can just grab the vector of tests and call std::test::run_tests, no extra work required.

Furthermore, I hope to build more sophisticated test frameworks on top of this one and you'll want to be able to build the test without building the test runner (then use reflection to dig out the tests).

But we can cross that bridge when it comes, and I'm not opposed to #[test] implying #[cfg(test)].

@marijnh
Copy link
Contributor Author

marijnh commented Nov 4, 2011

Well, seems you've thought this through. I don't think this is that important -- I just thought it looked like an oversight. Closing this issue.

@marijnh marijnh closed this as completed Nov 4, 2011
@brson brson reopened this Nov 4, 2011
@brson
Copy link
Contributor

brson commented Nov 4, 2011

I'd like to leave it open. It's a worthy idea and it might yet be the right behavior.

@ghost ghost assigned brson Jan 5, 2012
@brson
Copy link
Contributor

brson commented Jan 6, 2012

Finally changed my mind. Implemented in c2c497f.

@brson brson closed this as completed Jan 6, 2012
bjorn3 added a commit to bjorn3/rust that referenced this issue Aug 6, 2021
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
* Fix missing function check descriptions

Co-authored-by: Zyad Hassan <[email protected]>

Co-authored-by: Zyad Hassan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc
Projects
None yet
Development

No branches or pull requests

2 participants