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

Multiple --package parameters #1528

Closed
SimonSapin opened this issue Apr 16, 2015 · 6 comments
Closed

Multiple --package parameters #1528

SimonSapin opened this issue Apr 16, 2015 · 6 comments
Labels
A-configuration Area: cargo config files and env vars E-easy Experience: Easy

Comments

@SimonSapin
Copy link
Contributor

If foo is a dependency, I can run its tests with cargo test -p foo or cargo test --package foo.

I’d like to test many dependencies with cargo test -p foo -p bar -p baz and take advantage of Cargo’s built-in parallelism.

Currently, a cargo command only accepts at most one -p parameter. So I have to run multiple commands: cargo test -p foo && cargo test -p bar && cargo test -p baz. These commands can not run in parallel with each other because of #354.

This also applies to other Cargo commands (build, doc, bench, …) that accept --package.

@alexcrichton alexcrichton added E-easy Experience: Easy A-configuration Area: cargo config files and env vars labels Apr 16, 2015
@fhahn
Copy link
Contributor

fhahn commented Jul 12, 2015

I would like to look into this. Would you mind elaborting on Cargo’s built-in parallelism briefly, just as a starting point?

@alexcrichton
Copy link
Member

@fhahn all of Cargo's parallelism is based on an internal DependencyQueue, if that queue determines two tasks as not depending on one another then they will be run in parallel automatically.

In the case of testing multiple packages, they'll already be inferred to not depend on one another, so they just need to be added to the job graph and the backend should take care of the rest.

@fhahn
Copy link
Contributor

fhahn commented Jul 13, 2015

Thanks @alexcrichton. I had a closer look and just want to make sure I understand correctly. It seems like compiling multiple packages that should be tested could be parallelized by passing multiple targets to ops::compile_targets. The actual execution of the tests does not seem to be backed by a task queue. Should the tests be executed in parallel as well?

@alexcrichton
Copy link
Member

Nah currently tests are already internally parallelized so it's fine to not execute them in parallel, we just need to make sure to build them in parallel.

@fhahn
Copy link
Contributor

fhahn commented Jul 16, 2015

At the moment I am looking for ways to compile tests for two packages in parallel. Currently I am trying to create targets for the test files of two packages, but after adding them to the queue in with compile, the queue seems to hang. Does this approach sound reasonable at all?
Unfortunately, I am not sure where the best place would be to add the tests of multiple packages to the queue.

@alexcrichton
Copy link
Member

Perhaps that's adding duplicate entries to the dependency graph? The input may just want to change from a package + slice of targets to just a slice of package + targets

bors added a commit that referenced this issue 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 bors closed this as completed in f0647ea Sep 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars E-easy Experience: Easy
Projects
None yet
Development

No branches or pull requests

3 participants