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

body::to_bytes doctest fails with default feature set #2687

Closed
whentze opened this issue Nov 6, 2021 · 0 comments · Fixed by #2688
Closed

body::to_bytes doctest fails with default feature set #2687

whentze opened this issue Nov 6, 2021 · 0 comments · Fixed by #2688
Labels
C-bug Category: bug. Something is wrong. This is bad!

Comments

@whentze
Copy link
Contributor

whentze commented Nov 6, 2021

Version

Current git master aka 8062714

Platform

Linux 5.14.0-4-amd64 #1 SMP Debian 5.14.16-1 (2021-11-03) x86_64 GNU/Linux

Description

I cloned the repo in order to hack on the code, and I started out by making sure I could run the tests.
That is, I did:

git clone https://github.com/hyperium/hyper
cd hyper
cargo test

However, one of the doctests fails to compile:

   Doc-tests hyper

running 6 tests
test src/ext.rs - ext::HeaderCaseMap (line 14) ... ignored
test src/ext.rs - ext::HeaderCaseMap (line 22) ... ignored
test src/body/to_bytes.rs - body::to_bytes::to_bytes (line 19) ... FAILED
test src/service/make.rs - service::make::make_service_fn (line 106) ... ok
test src/service/util.rs - service::util::service_fn (line 13) ... ok
test src/body/body.rs - body::body::Body::empty (line 123) ... ok

failures:

---- src/body/to_bytes.rs - body::to_bytes::to_bytes (line 19) stdout ----
error[E0433]: failed to resolve: could not find `Client` in `hyper`
  --> src/body/to_bytes.rs:28:21
   |
12 | let client = hyper::Client::new();
   |                     ^^^^^^ could not find `Client` in `hyper`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.

failures:
    src/body/to_bytes.rs - body::to_bytes::to_bytes (line 19)

test result: FAILED. 3 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.27s

It looks like the test depends on some feature(s) outside of the default set.
I successfully fixed the issue locally by adding a #[cfg(...)] guard to the test, but I'm not sure if the real bug is in fact that the test depends on extra features.

Also, there seems to be a CI job that runs the test against many feature sets. For some reason it did not catch this. Maybe I'm looking at the wrong thing, or the job is buggy, or it's just really bad luck. In any case, might be worth investigating.

@whentze whentze added the C-bug Category: bug. Something is wrong. This is bad! label Nov 6, 2021
whentze added a commit to whentze/hyper that referenced this issue Nov 6, 2021
The doctest uses `hyper::Client`, but that is not available unless these features are enabled.
Adding the attribute allows `cargo test` with no arguments to pass again.

fixes hyperium#2687.
whentze added a commit to whentze/hyper that referenced this issue Nov 6, 2021
when testing my fix for hyperium#2687, I noticed that this doctest has the same issue,
so here's another fix.
whentze added a commit to whentze/hyper that referenced this issue Nov 6, 2021
The doctest uses `hyper::Client`, but that is not available unless these features are enabled.
This commit adds an attribute to check for those and allows `cargo test` with no arguments to pass again.

fixes hyperium#2687.
whentze added a commit to whentze/hyper that referenced this issue Nov 6, 2021
when testing my fix for hyperium#2687, I noticed that this doctest has the same issue,
so here's another fix.
seanmonstar pushed a commit that referenced this issue Nov 8, 2021
The doctest uses `hyper::Client`, but that is not available unless these features are enabled.
This commit adds an attribute to check for those and allows `cargo test` with no arguments to pass again.

fixes #2687.
seanmonstar pushed a commit that referenced this issue Nov 8, 2021
when testing my fix for #2687, I noticed that this doctest has the same issue,
so here's another fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant