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

Compile tests for multiple packages #1828

Merged
merged 7 commits into from
Sep 30, 2015

Conversation

fhahn
Copy link
Contributor

@fhahn fhahn commented Jul 24, 2015

This PR for #1528 is still pretty rough (and so far only added multiple package support for tests), but I wanted to make sure the overall approach is fine.

I have made some progress and cargo is now able to compile and execute tests for multiple packages.

In order to execute the doc tests for multiple packages as well, I added to_doc_test to Compilation (used here). Previously it only executed the doc tests for Compilation.package. Another option would be to change Compilation.package to be a Vec<Package>, because in order to execute the tests of multiple packages, multiple packages are compiled as "top level package". But this would require a changes at a couple of other places.

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@fhahn fhahn force-pushed the multiple-package-parameters branch from 8b8df3e to 64a8cb0 Compare July 24, 2015 11:23
@@ -26,7 +26,7 @@ pub const USAGE: &'static str = "
Execute all unit and integration tests of a local package

Usage:
cargo test [options] [--] [<args>...]
cargo test [options] [-p SPEC --package SPEC]... [--] [<args>...]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @BurntSushi, you mentioned on docopt/docopt#275 that you were thinking of proposing the ability to do this in the options section instead of up here in the usage section, do you know if there's been progress on that? I wouldn't mind proposing an idea or two on that thread to see if I can get discussion rolling again, it'd be great to fix :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton Thanks for the reminder! I have a candidate implementation working in 0.6.69. See my proposal for details: docopt/docopt#275 (Even though it's working in the Rust implementation, I probably wouldn't add it into Cargo quite yet in case the proposal changes. If it's ultimately rejected, I might still leave it in because I think it's really really useful.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, thanks @BurntSushi!

@alexcrichton
Copy link
Member

Yeah this all looks like a pretty good approach to me!

@fhahn fhahn force-pushed the multiple-package-parameters branch from 64a8cb0 to 44957f6 Compare July 24, 2015 21:08
@fhahn fhahn force-pushed the multiple-package-parameters branch from a56fd80 to 38335d8 Compare August 2, 2015 22:04
@bors
Copy link
Contributor

bors commented Aug 4, 2015

☔ The latest upstream changes (presumably #1830) made this pull request unmergeable. Please resolve the merge conflicts.

@fhahn fhahn force-pushed the multiple-package-parameters branch 3 times, most recently from 35c6833 to 4f7f409 Compare September 6, 2015 21:05
@fhahn
Copy link
Contributor Author

fhahn commented Sep 6, 2015

I finally had time to work on this PR again. I have started adding tests, but I am not sure how to test cargo test and cargo bench, because the output order is non deterministic for multiple packages (e.g. test_cargo_test::test_multiple_packages) Any ideas whats a good way to test this would be?

@bors
Copy link
Contributor

bors commented Sep 8, 2015

☔ The latest upstream changes (presumably #1973) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

The nondeterminism may be solved by -j1, but if that doesn't work then just testing that they're accepted should be fine.

@@ -26,7 +26,7 @@ pub const USAGE: &'static str = "
Execute all benchmarks of a local package

Usage:
cargo bench [options] [--] [<args>...]
cargo bench [options] [-p SPEC --package SPEC]... [--] [<args>...]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that new syntax in docopt may actually allow for nicer definitions of this, something like:

Options:
    -p, --package=SPEC ...         Description ...

I believe it's still somewhat experimental, but this may be a good place to get a good start on it?

@fhahn
Copy link
Contributor Author

fhahn commented Sep 30, 2015

I've squashed the commits down to 6, but I could reduce the number even further if necessary.

@alexcrichton
Copy link
Member

Looks like this may have accidentally picked up some other commits, perhaps a rebase is in order? I'll give this one last look-through but I'll probably just send it to bors.

@alexcrichton
Copy link
Member

Now that I've actually gotten around to taking a peek, this looks fantastic to me. Thanks so much again for pushing on this @fhahn!

@bors: r+ d9615d7

bors added a commit that referenced this pull request Sep 30, 2015
This PR for #1528 is still pretty rough (and so far only added multiple package support for tests), but I wanted to make sure the overall approach is fine.

I have made some progress and cargo is now able to compile and execute tests for multiple packages. 

In order to execute the doc tests for multiple packages as well, I added `to_doc_test` to `Compilation` (used [here](fhahn@8b8df3e#diff-417e085367d0ce027505dfaa26a089d3R33)). Previously it only executed the doc tests for `Compilation.package`. Another option would be to change `Compilation.package` to be a `Vec<Package>`, because in order to execute the tests of multiple packages, multiple packages are compiled as "top level package". But this would require a changes at a couple of other places.
@bors
Copy link
Contributor

bors commented Sep 30, 2015

⌛ Testing commit d9615d7 with merge 7931e58...

@bors
Copy link
Contributor

bors commented Sep 30, 2015

@bors bors merged commit d9615d7 into rust-lang:master Sep 30, 2015
@fhahn fhahn deleted the multiple-package-parameters branch October 1, 2015 09:28
@fhahn
Copy link
Contributor Author

fhahn commented Oct 1, 2015

Great, thanks @alexcrichton for your patience :)

SimonSapin added a commit to servo/servo that referenced this pull request Oct 1, 2015
Upgrade Cargo to get rust-lang/cargo#1828,
and use it for unit tests.
This allows Cargo to get some more parallelism
when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine
goes from 149 seconds to 124.
bors-servo pushed a commit to servo/servo that referenced this pull request Oct 1, 2015
Run all unit tests with just one Cargo command.

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7813)
<!-- Reviewable:end -->
SimonSapin added a commit to servo/servo that referenced this pull request Oct 1, 2015
Upgrade Cargo to get rust-lang/cargo#1828,
and use it for unit tests.
This allows Cargo to get some more parallelism
when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine
goes from 149 seconds to 124.
bors-servo pushed a commit to servo/servo that referenced this pull request Oct 1, 2015
Run all unit tests with just one Cargo command.

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7813)
<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Oct 1, 2015
Run all unit tests with just one Cargo command.

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7813)
<!-- Reviewable:end -->
jrmuizel pushed a commit to jrmuizel/gecko-cinnabar that referenced this pull request Jun 12, 2017
…from servo:parallel-unit-tests); r=mbrubeck

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

Source-Repo: https://github.com/servo/servo
Source-Revision: ba2714f4f607da77bd7200f88cfa16c1d10da9cd
bors added a commit that referenced this pull request Apr 1, 2019
Allow `cargo doc --open` with multiple packages.

If `cargo doc --open` builds multiple packages, open the first one. This seems pretty natural to me (the first one on the command line, or the first default member if `default-members` is specified, or the root of a workspace). Rustdoc shows a list of crates in the sidebar, so if it doesn't open the one the user wants, it's a trivial matter of clicking on the crate name.

@alexcrichton specifically asked for an error [here](#1828 (diff)). However, at the time I don't think rustdoc dynamically generated the "Crates" listing in the sidebar. Alex, I wonder if your stance still holds?

Closes #5145
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Sep 30, 2019
…from servo:parallel-unit-tests); r=mbrubeck

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

Source-Repo: https://github.com/servo/servo
Source-Revision: ba2714f4f607da77bd7200f88cfa16c1d10da9cd

UltraBlame original commit: a747ff057fac88586b57a543cf00052e24c93afe
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…from servo:parallel-unit-tests); r=mbrubeck

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

Source-Repo: https://github.com/servo/servo
Source-Revision: ba2714f4f607da77bd7200f88cfa16c1d10da9cd

UltraBlame original commit: a747ff057fac88586b57a543cf00052e24c93afe
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…from servo:parallel-unit-tests); r=mbrubeck

Upgrade Cargo to get rust-lang/cargo#1828, and use it for unit tests. This allows Cargo to get some more parallelism when compiling the test crates’ dependencies.

`touch components/util/lib.rs && mach test-unit` on my machine goes from 149 seconds to 124.

Source-Repo: https://github.com/servo/servo
Source-Revision: ba2714f4f607da77bd7200f88cfa16c1d10da9cd

UltraBlame original commit: a747ff057fac88586b57a543cf00052e24c93afe
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.

6 participants