-
Notifications
You must be signed in to change notification settings - Fork 4
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
Code that is only used in test cases can be put behind #[cfg(test)]
.
#5
Comments
Confirmed; I think code that is only used in test cases should at the very least be behind a |
#[cfg(test)]
.
Example: const X: usize = 0;
const Y: usize = 0;
#[test]
fn test() {
let _ = Y;
}
fn main() {
println!("Hello, world!");
} A #[cfg(test)]
const Y: usize = 0;
#[test]
fn test() {
let _ = Y;
}
fn main() {
println!("Hello, world!");
} |
Another use case: fn main() {
println!("Hello, world!");
}
fn bar() -> bool {
true
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn foo() {
assert!(bar());
}
} |
This could be split into two features. One would be to check if it's only used in a test environment, and the other if it's only used inside a specific module (since it doesn't have to specifically be a |
What the title says. I thought this would show up but in a test I'm running it didn't.
The text was updated successfully, but these errors were encountered: