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

Doc-tests not compiled ok when setted as no_run on target x86_64-unknown-linux-musl #31907

Closed
zitsen opened this issue Feb 26, 2016 · 3 comments · Fixed by rust-lang/cargo#2485
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@zitsen
Copy link

zitsen commented Feb 26, 2016

To list usage in documents, add a example in the lib.rs documents with mark no_run. It's ok when
target not setted(it's x86_64-unknown-linux-gnu), but failed on target x86_64-unknown-linux-musl:

I tried this code:

cargo new doc-tests-no-run-bug

src/lib.rs:

//! ```no_run
//! extern crate doc_tests_no_run_bug;
//! fn main() {
//!   assert!(false);
//! }
//! ```

#[cfg(test)]
mod test {
    #[test]
    fn it_works() {
    }
}

default test is ok:

# Run: cargo test
     Running target/debug/doc_tests_no_run_bug-cffd3fd286caef08

running 1 test
test test::it_works ... ok

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

   Doc-tests doc-tests-no-run-bug

running 1 test
test _0 ... ok

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

Test it on target x86_64-unknown-linux-musl:

cargo test --target=x86_64-unknown-linux-musl

Doc-tests should not run as I expected, but it fails as this:

running 1 test
test test::it_works ... ok

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

   Doc-tests doc-tests-no-run-bug

running 1 test
test _0 ... FAILED

failures:

---- _0 stdout ----
    <anon>:1:1: 1:35 error: couldn't find crate `doc_tests_no_run_bug` with expected target triple x86_64-unknown-linux-gnu [E0461]
<anon>:1 extern crate doc_tests_no_run_bug;
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:1:1: 1:35 note: crate `doc_tests_no_run_bug`, path #1, triple x86_64-unknown-linux-musl: /home/mypath/doc-tests-no-run-bug/target/x86_64-unknown-linux-musl/debug/libdoc_tests_no_run_bug.rlib
error: aborting due to previous error
thread '_0' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:607
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread '_0' panicked at 'couldn't compile the test', ../src/librustdoc/test.rs:280


failures:
    _0

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured

Meta

rustc --version --verbose:

rustc 1.8.0-dev (798ce4ab5 2016-02-25)
binary: rustc
commit-hash: 798ce4ab59ab2ca84caacc4472499409a8516db3
commit-date: 2016-02-25
host: x86_64-unknown-linux-gnu
release: 1.8.0-dev

Backtrace:

RUST_BACKTRACE=1 cargo test --target=x86_64-unknown-linux-musl

Result:

   Compiling doc-tests-no-run-bug v0.1.0 (file:///xxx/doc-tests-no-run-bug)

     Running target/x86_64-unknown-linux-musl/debug/doc_tests_no_run_bug-cffd3fd286caef08

running 1 test
test test::it_works ... ok

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

   Doc-tests doc-tests-no-run-bug

running 1 test
test _0 ... FAILED

failures:

---- _0 stdout ----
    <anon>:1:1: 1:35 error: couldn't find crate `doc_tests_no_run_bug` with expected target triple x86_64-unknown-linux-gnu [E0461]
<anon>:1 extern crate doc_tests_no_run_bug;
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:1:1: 1:35 note: crate `doc_tests_no_run_bug`, path #1, triple x86_64-unknown-linux-musl: /xxx/doc-tests-no-run-bug/target/x86_64-unknown-linux-musl/debug/libdoc_tests_no_run_bug.rlib
error: aborting due to previous error
thread '_0' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:607
stack backtrace:
   1:     0x7fadd9059fd0 - sys::backtrace::tracing::imp::write::hd6d99fcaca6f3487qru
   2:     0x7fadd9062f9b - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.43421
   3:     0x7fadd9062af3 - panicking::default_handler::hd56ae5efa8870fb8eZy
   4:     0x7fadd902b90c - sys_common::unwind::begin_unwind_inner::hddffc5a57d251d30fgt
   5:     0x7fadd4d14297 - sys_common::unwind::begin_unwind::h8186529389946867416
   6:     0x7fadd4d14170 - errors::Handler::abort_if_errors::ha1e2ef558ecc9b01lVd
   7:     0x7fadd7848a23 - loader::Context<'a>::report_load_errs::hf989e542067ac336cTl
   8:     0x7fadd7845b8f - loader::Context<'a>::load_library_crate::hd4c66c69e84d8b3fySl
   9:     0x7fadd7844909 - creader::CrateReader<'a>::resolve_crate::h542e175397ef02b3g3j
  10:     0x7fadd783f40e - creader::LocalCrateReader<'a, 'b>.Visitor<'hir>::visit_item::hfa765e8eb352b635QCj
  11:     0x7fadd7851b9e - creader::LocalCrateReader<'a, 'b>::read_crates::h7df930f9047d0fd8Gvk
  12:     0x7fadd8888bad - driver::phase_3_run_analysis_passes::h16257317625067277007
  13:     0x7fadd885cdaa - driver::compile_input::ha4ae3a60f7db99f6Bca
  14:     0x7fadd96f715f - sys_common::unwind::try::try_fn::h3639206756227387971
  15:     0x7fadd90578fb - __rust_try
  16:     0x7fadd904ff2d - sys_common::unwind::inner_try::h3542d60f67fb7f36hdt
  17:     0x7fadd96f36dd - test::runtest::haef3dfd286ad2a757tu
  18:     0x7fadd96f7e26 - boxed::F.FnBox<A>::call_box::h7907733678206165708
  19:     0x7fadd1b6686b - sys_common::unwind::try::try_fn::h17857959527288479610
  20:     0x7fadd90578fb - __rust_try
  21:     0x7fadd904ff2d - sys_common::unwind::inner_try::h3542d60f67fb7f36hdt
  22:     0x7fadd1b66bea - boxed::F.FnBox<A>::call_box::h17375982074145669126
  23:     0x7fadd9061560 - sys::thread::Thread::new::thread_start::h59456e26addaa3d3yWx
  24:     0x7fadd1240181 - start_thread
  25:     0x7fadd8cd047c - __clone
  26:                0x0 - <unknown>
thread '_0' panicked at 'couldn't compile the test', ../src/librustdoc/test.rs:280
stack backtrace:
   1:     0x7fadd9059fd0 - sys::backtrace::tracing::imp::write::hd6d99fcaca6f3487qru
   2:     0x7fadd9062f9b - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.43421
   3:     0x7fadd9062af3 - panicking::default_handler::hd56ae5efa8870fb8eZy
   4:     0x7fadd902b90c - sys_common::unwind::begin_unwind_inner::hddffc5a57d251d30fgt
   5:     0x7fadd953a2ff - sys_common::unwind::begin_unwind::h15274598743891702961
   6:     0x7fadd96f529a - test::runtest::haef3dfd286ad2a757tu
   7:     0x7fadd96f7e26 - boxed::F.FnBox<A>::call_box::h7907733678206165708
   8:     0x7fadd1b6686b - sys_common::unwind::try::try_fn::h17857959527288479610
   9:     0x7fadd90578fb - __rust_try
  10:     0x7fadd904ff2d - sys_common::unwind::inner_try::h3542d60f67fb7f36hdt
  11:     0x7fadd1b66bea - boxed::F.FnBox<A>::call_box::h17375982074145669126
  12:     0x7fadd9061560 - sys::thread::Thread::new::thread_start::h59456e26addaa3d3yWx
  13:     0x7fadd1240181 - start_thread
  14:     0x7fadd8cd047c - __clone
  15:                0x0 - <unknown>


failures:
    _0

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured

@zitsen zitsen changed the title Doc-tests not ignored when setted as no_run on target x86_64-unknown-linux-musl Doc-tests not compiled ok when setted as no_run on target x86_64-unknown-linux-musl Feb 26, 2016
@alexcrichton
Copy link
Member

I believe there are two bugs at play here:

  1. Cargo isn't passing --target to rustdoc, which is because of...
  2. Rustdoc doesn't handle --target correctly. I think it assumes it can always generate documentation tests for the host platform.

Cargo should probably just ignore documentation tests for anything that's not the host platform as you're not really guaranteed to be able to run it anywhere else.

@steveklabnik
Copy link
Member

Yes, Rustdoc should ignore doc tests for cross, IMHO. I think that's probably better than cargo, though it would save time by never invoking Rustdoc

On Feb 26, 2016, 12:07 -0500, Alex Crichtonnotifications@github.com, wrote:

I believe there are two bugs at play here:

Cargo isn't passing--targetto rustdoc, which is because of...
Rustdoc doesn't handle--targetcorrectly. I think it assumes it can always generate documentation tests for the host platform.

Cargo should probably just ignore documentation tests for anything that's not the host platform as you're not really guaranteed to be able to run it anywhere else.


Reply to this email directly orview it on GitHub(#31907 (comment)).

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 26, 2016
japaric pushed a commit to japaric-archived/rust-everywhere that referenced this issue Mar 8, 2016
japaric pushed a commit to japaric/cargo that referenced this issue Mar 15, 2016
bors added a commit to rust-lang/cargo that referenced this issue Mar 15, 2016
bors added a commit to rust-lang/cargo that referenced this issue Mar 15, 2016
@jan-hudec
Copy link

Why should it ignore doc tests on cross-compile?

I have successfully configured the system to run the normal tests on cross-compilation (it would be better if cargo had interpreter support, but Linux binfmt support works for most cases). So shouldn't it be possible to fix building doc tests so they run too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants