Skip to content

OUT_DIR not set when building doc tests #908

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

Closed
chris-morgan opened this issue Nov 19, 2014 · 1 comment
Closed

OUT_DIR not set when building doc tests #908

chris-morgan opened this issue Nov 19, 2014 · 1 comment

Comments

@chris-morgan
Copy link
Member

Cargo.toml:

[package]
name = "foo"
version = "0.0.1"
authors = []
build = "build.rs"

src/lib.rs:

fn it_works() {
    println!("{}", env!("OUT_DIR"));
}

build.rs:

fn main() { }

Now, cargo build works and the first part of cargo test works, but when it gets to the doc tests, it falls apart:

$ cargo test
   Compiling foo v0.0.1 (file:///tmp/foo)
/tmp/foo/src/lib.rs:1:1: 3:2 warning: function is never used: `it_works`, #[warn(dead_code)] on by default
/tmp/foo/src/lib.rs:1 fn it_works() {
/tmp/foo/src/lib.rs:2     println!("{}", env!("OUT_DIR"));
/tmp/foo/src/lib.rs:3 }
     Running target/foo-9c5c49d595bfa18b

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests foo
/tmp/foo/src/lib.rs:2:5: 2:37 error: environment variable `OUT_DIR` not defined
/tmp/foo/src/lib.rs:2     println!("{}", env!("OUT_DIR"));
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
task '<main>' panicked at 'Box<Any>', /home/chris/rust/src/libsyntax/diagnostic.rs:142

This is completely crippling.

I presume the other environment variables aren’t set either, but I haven’t checked.

@alexcrichton
Copy link
Member

Fixed in #897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants