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

Guide new users to add use super::*; to mod test #10706

Merged
merged 5 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,17 @@ fn main() {
"
} else {
b"\
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Expand Down
8 changes: 7 additions & 1 deletion tests/testsuite/init/auto_git/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/formats_source/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/fossil_autodetect/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/git_autodetect/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/mercurial_autodetect/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/pijul_autodetect/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/simple_git/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/simple_hg/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 7 additions & 1 deletion tests/testsuite/init/simple_lib/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
10 changes: 8 additions & 2 deletions tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ fn simple_lib() {
let contents = fs::read_to_string(&lib).unwrap();
assert_eq!(
contents,
r#"#[cfg(test)]
r#"pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = 2 + 2;
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Expand Down