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

Automatically check if README.md examples are working when running "cargo test" #657

Merged
merged 3 commits into from
May 1, 2019

Conversation

GuillaumeGomez
Copy link
Contributor

Since rustdoc nightly now provides "cfg(test)" when running on test mode, we can now use this macro on test mode only to check if README.md examples are working as expected.

@cuviper
Copy link
Member

cuviper commented May 1, 2019

How do I know if this worked? I don't see README tests in the log:
https://travis-ci.org/rayon-rs/rayon/jobs/525713032

@GuillaumeGomez
Copy link
Contributor Author

GuillaumeGomez commented May 1, 2019

It only work on nightly for the moment. The PR got merged recently: rust-lang/rust#59940, so in 6 weeks it'll be in beta and then on stable (but you already know how it works I assume ;) ).

I can add tests for nightly on your CI if you want alongside the others?

@cuviper
Copy link
Member

cuviper commented May 1, 2019

Ah, we do have CI for nightly, but only on the full bors check. Let's just go for it:

bors r+

bors bot added a commit that referenced this pull request May 1, 2019
657: Automatically check if README.md examples are working when running "cargo test" r=cuviper a=GuillaumeGomez

Since rustdoc nightly now provides "cfg(test)" when running on test mode, we can now use this macro on test mode only to check if README.md examples are working as expected.

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 1, 2019

Build failed

@GuillaumeGomez
Copy link
Contributor Author

Can you tell me what failed please? :)

@cuviper
Copy link
Member

cuviper commented May 1, 2019

Looks like a UI issue in rayon-core, unrelated to your change:

---- src/compile_fail/scope_join_bad.rs - compile_fail::scope_join_bad (line 1) stdout ----
error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
 --> src/compile_fail/scope_join_bad.rs:8:17
  |
7 |     rayon_core::scope(|s| {
  |                        - has type `&rayon_core::Scope<'1>`
8 |         let x = 22;
9 |         s.spawn(|_| f(&x)); //~ ERROR `x` does not live long enough
  |                 ^^^    - `x` is borrowed here
  |                 |
  |                 may outlive borrowed value `x`
  |
note: function requires argument type to outlive `'1`
 --> src/compile_fail/scope_join_bad.rs:8:9
  |
9 |         s.spawn(|_| f(&x)); //~ ERROR `x` does not live long enough
  |         ^^^^^^^^^^^^^^^^^^
help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword
  |
9 |         s.spawn(move |_| f(&x)); //~ ERROR `x` does not live long enough
  |                 ^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0373`.
thread 'src/compile_fail/scope_join_bad.rs - compile_fail::scope_join_bad (line 1)' panicked at 'Some expected error codes were not found: ["E0597"]', src/librustdoc/test.rs:315:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

@GuillaumeGomez
Copy link
Contributor Author

Oh? That's surprising. Well, I'll let you handle this part then. Thanks for showing me the error! :)

@cuviper
Copy link
Member

cuviper commented May 1, 2019

I believe the error change is from NLL being enabled for 2015 edition. Fortunately, compile_fail doc tests still only check the error string on nightly, so we don't have to worry about matching older errors.

bors r+

bors bot added a commit that referenced this pull request May 1, 2019
657: Automatically check if README.md examples are working when running "cargo test" r=cuviper a=GuillaumeGomez

Since rustdoc nightly now provides "cfg(test)" when running on test mode, we can now use this macro on test mode only to check if README.md examples are working as expected.

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 1, 2019

Build failed

@cuviper
Copy link
Member

cuviper commented May 1, 2019

Bah, more error changes in rayon-futures...

@cuviper
Copy link
Member

cuviper commented May 1, 2019

bors r+

bors bot added a commit that referenced this pull request May 1, 2019
657: Automatically check if README.md examples are working when running "cargo test" r=cuviper a=GuillaumeGomez

Since rustdoc nightly now provides "cfg(test)" when running on test mode, we can now use this macro on test mode only to check if README.md examples are working as expected.

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 1, 2019

@bors bors bot merged commit 4547a27 into rayon-rs:master May 1, 2019
@GuillaumeGomez GuillaumeGomez deleted the doc-tests branch May 2, 2019 07:52
@GuillaumeGomez
Copy link
Contributor Author

Congrats and thanks for fixing!

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

Successfully merging this pull request may close these issues.

None yet

2 participants