Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Not all required crates are added to doctests #219

Open
hjr3 opened this issue Dec 11, 2017 · 3 comments
Open

Not all required crates are added to doctests #219

hjr3 opened this issue Dec 11, 2017 · 3 comments

Comments

@hjr3
Copy link
Contributor

hjr3 commented Dec 11, 2017

Download hyper and checkout tag v0.11.9. Run the tests:

RUST_BACKTRACE=1 cargo run --bin rustdoc -- --manifest-path=../hyper/Cargo.toml test

The tests fail because the test program does not extern the base64 crate.

     Running `target/debug/rustdoc --manifest-path=../hyper/Cargo.toml test`
  Generating save analysis data: Done
  Loading save analysis data: Done
  Generating JSON: Done
  Generating documentation: Done
running 2 tests
test hyper::header - 0 ... FAILED
test hyper::header - 1 ... FAILED

---- hyper::header - 0 stderr ----
error[E0463]: can't find crate for `base64` which `hyper` depends on
 --> <anon>:1:17
  |
1 | # [ macro_use ] extern crate hyper ; use hyper :: header :: Headers ; header ! { ( XRequestGuid , "X-Request-Guid" ) => [ String ] } fn main ( ) { let mut headers = Headers :: new ( ) ; headers . set ( XRequestGuid ( "a proper guid" . to_owned ( ) ) ) }
  |                 ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

---- hyper::header - 1 stderr ----
error[E0463]: can't find crate for `base64` which `hyper` depends on
 --> <anon>:1:1
  |
1 | extern crate hyper ; fn main ( ) { use std :: fmt ; use hyper :: header :: { self , Header , Raw } ; # [ derive ( Debug , Clone , Copy ) ] struct Dnt ( bool ) ; impl Header for Dnt { fn header_name ( ) -> & 'static str { "DNT" } fn parse_header ( raw : & Raw ) -> hyper :: Result < Dnt > { if raw . len ( ) == 1 { let line = & raw [ 0 ] ; if line . len ( ) == 1 { let byte = line [ 0 ] ; match byte { b'0' => return Ok ( Dnt ( true ) ) , b'1' => return Ok ( Dnt ( false ) ) , _ => ( ) , } } } Err ( hyper :: Error :: Header ) } fn fmt_header ( & self , f : & mut header :: Formatter ) -> fmt :: Result { let value = if self . 0 { "1" } else { "0" } ; f . fmt_line ( & value ) } } }
  | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

failures:
    hyper::header - 0
    hyper::header - 1

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
@hjr3
Copy link
Contributor Author

hjr3 commented Dec 12, 2017

Not sure this is solvable without leveraging more of cargo. The approach of compiling using rustc will lead us down a path of basically recreating cargo. Already looking at this I ran into issues where a crate like hyper has two different versions of the slab crate.

@euclio
Copy link
Contributor

euclio commented Dec 14, 2017

Maybe rust-lang/cargo#3815 would help?

@hjr3
Copy link
Contributor Author

hjr3 commented Dec 19, 2017

I tracked this down to a missing -L arg when building the artifact. I will fix this in #218 but if that does not land, I will make a separate PR.

hjr3 added a commit to hjr3/rustdoc that referenced this issue Jan 7, 2018
When generating documentation tests, the following stages will happen:

- tests will be gathered from the docs as a list of strings
- tests will be saved to target/doc/tests as individual files
- tests will be compiled into a single binary called "rustdoc-test"
- tests will be run by executing the "rustdoc-test" binary

Doc tests are now actual tests. This allows us to take advantage of the
existing test infrastructure supplied by rustc.

Fixes steveklabnik#32, steveklabnik#54, steveklabnik#219
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants