diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-02-02 22:22:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-02 22:22:19 +0100 |
| commit | 5ada328d81a75a19163a038555669e36070edf5d (patch) | |
| tree | c09894e673d9ad4fc281f8a5794bf32ab9ab5ff6 /src/test/incremental/thinlto | |
| parent | a47a6ea771ca4426b6bba29219bdc7d2bceec3d5 (diff) | |
| parent | b996a7ecec4bb22a28bce3b86f68fe51b4409287 (diff) | |
| download | rust-5ada328d81a75a19163a038555669e36070edf5d.tar.gz rust-5ada328d81a75a19163a038555669e36070edf5d.zip | |
Rollup merge of #38823 - Freyskeyd:doc-missingInformationCfgTest, r=steveklabnik
Improve doc cfg(test) and tests directory
Hi,
I was facing a problem with my code organisation. I was using a tests directory and i defined some `#[cfg(test)]` in my `src/`. But i was not able to use it in my `tests` folder.
```bash
.
├── Cargo.lock
├── Cargo.toml
├── src
│ ├── lib.rs
│ └── test.rs
└── tests
└── x.rs
```
> src/lib.rs
```rust
pub mod test;
fn tesst() {
assert!(test::t());
}
```
> src/test.rs
```rust
pub fn t() -> bool { true }
```
> test/x.rs
```rust
extern crate testt;
use testt::test;
fn tesst() {
assert!(test::t());
}
```
I was unable to compile using `cargo test`:
```bash
error[E0432]: unresolved import `testt::test`
--> tests/x.rs:3:5
|
3 | use testt::test;
| ^^^^^^^^^^^ no `test` in `testt`
```
If i remove the `tests` directory everything works fine. To use an utils module in your `tests` directory, you need to create a module in the directory (like `tests/utils.rs`). My `tests/x.rs` look like this now:
```rust
extern crate testt;
mod utils;
fn tesst() {
assert!(utils::t());
}
```
And my tree:
```bash
.
├── Cargo.lock
├── Cargo.toml
├── src
│ └── lib.rs
└── tests
├── utils.rs
└── x.rs
```
I think that thing must be documented in the book.
Ping:
- @badboy : Because he's the one who showed me the path
- @shahn : Because he helped me too to find the solution
Signed-off-by: Freyskeyd <simon.paitrault@iadvize.com>
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
