Skip to content

Add --exclude flag - #4031

Merged
bors merged 5 commits into
rust-lang:masterfrom
torkleyy:exclude
May 28, 2017
Merged

Add --exclude flag#4031
bors merged 5 commits into
rust-lang:masterfrom
torkleyy:exclude

Conversation

@torkleyy

Copy link
Copy Markdown

Allows to exclude packages in conjunction
with --all.

Addresses #2878

@rust-highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@torkleyy torkleyy left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

First contribution, would really appreciate if somebody could answer my questions.

Comment thread src/bin/build.rs Outdated

@torkleyy torkleyy May 11, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

How would I return a proper error here? More specifically, should I build the CargoError myself or is there some convenience function? Can I use the bail! macro from there?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, bail! is for this use case:

let cfg = match color {
Some("auto") => Auto,
Some("always") => Always,
Some("never") => Never,
None => Auto,
Some(arg) => bail!("argument for --color must be auto, always, or \
never, but found `{}`", arg),
};

Comment thread src/bin/build.rs Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This match would be used in many subcommands. May I place it in cargo::util?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could add Packages::from_flags(flag_all, flag_exclude) -> CargoResult<Packeges>.

Comment thread src/bin/build.rs Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It seems pretty verbose to manually handle conflicts / requirements of flags. Is there a way to let docopt do this? There is currently sort of a bug when executing cargo build -p whatever --all: The -p is silently ignored.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a way to let docopt do this?

Basically we need to switch to clap, and hopefully get rid of a lot of duplication along the way. But this is a hard task :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Basically we need to switch to clap

Oh it is desired to switch to clap? It's good to hear that! Is there someone working on it already? If not, I'd love to do it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there someone working on it already?

I've tried to do that, but haven't arrived at something very satisfying :)

It would be super if you would be able to pull this off!

@torkleyy
torkleyy force-pushed the exclude branch 3 times, most recently from fb72d95 to 82cc47e Compare May 12, 2017 14:52
@torkleyy torkleyy changed the title [WIP] Add --exclude flag Add --exclude flag May 12, 2017
@torkleyy

Copy link
Copy Markdown
Author

I'd say this is ready for review.

@matklad

matklad commented May 15, 2017

Copy link
Copy Markdown
Contributor

@alexcrichton what do you think about it? I feel that we definitely need something like this, but I am worried that we will have three flags (-pkg, -all, -exclude) to control this behavior.

Hm, maybe we want --pkg foo, --pkg -foo, --pkg *?

@torkleyy

Copy link
Copy Markdown
Author

@matklad is "-foo" allowed as argument? If that's the case, I agree that it makes more sense to only have one flag for all of them. Just used --exclude because it was mentionend in that issue.

@alexcrichton

Copy link
Copy Markdown
Member

Thanks for the PR @torkleyy! This seems fine to me, @matklad we've got enough flags at this point for "target selection" that it may make sense to basically house their documentation elsewhere at some point. Do you think canonicalizing in one --pkg argument with some syntax is better though? I feel like apart from docs --exclude at least is more self-explanatory than --pkg -foo.

@bors

bors commented May 16, 2017

Copy link
Copy Markdown
Contributor

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

@torkleyy

Copy link
Copy Markdown
Author

Rebased

@matklad

matklad commented May 16, 2017

Copy link
Copy Markdown
Contributor

I feel like apart from docs --exclude at least is more self-explanatory than --pkg -foo.

Yeah, --exclude is good enough. It's not obvious though what exactly are you excluding:

cargo test --all --exclude baz

Are we excluding baz package or baz module here?

Another option for flag name is --exclude--pkg.

@torkleyy

Copy link
Copy Markdown
Author

@matklad I feel excluding a module would be a cheat somehow, so I wouldn't expect it to be possible with cargo. Also you can easily read the description of --exclude. We shouldn't make the flag longer than necessary.

@torkleyy

torkleyy commented May 16, 2017

Copy link
Copy Markdown
Author

It seems we got platform-specific behavior here:

I implemented a test which checks for this pattern:

"[..] Compiling bar v0.1.0 ([..])\n\
[..] Compiling foo v0.1.0 ([..])\n

It matches on Linux, however on Windows it seems to compile the crates the other way around.

EDIT: Now it even fails locally, so apparently behavior has changed. Fixing..
Huh? It fails both ways now... What's going on?

@matklad

matklad commented May 16, 2017

Copy link
Copy Markdown
Contributor

Huh? It fails both ways now... What's going on?

I bet foo and bar just compile in parallel in arbitrary order. You can use with_stderr_contains and with_stderr_does_not_contain (or you can put broken code in the excluded package and check that it does not break compilation).

Hm, what would happen if you compile foo and exclude bar if foo depends on bar? Should we add this test case?

@torkleyy

Copy link
Copy Markdown
Author

exclude bar if foo depends on bar? Should we add this test case?

Oops, thought about this, but completely forgot it!

I'm not sure actually. I think the current behavior is just compiling it if it's a dependency.

@matklad

matklad commented May 25, 2017

Copy link
Copy Markdown
Contributor

Let's assign @alexcrichton to this :)

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned brson May 25, 2017
@alexcrichton alexcrichton added the relnotes Release-note worthy label May 26, 2017
@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

Looks great to me, thanks again for the PR @torkleyy!

@bors

bors commented May 26, 2017

Copy link
Copy Markdown
Contributor

📌 Commit 9ad240b has been approved by alexcrichton

@bors

bors commented May 26, 2017

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9ad240b with merge 50791b8...

@bors

bors commented May 26, 2017

Copy link
Copy Markdown
Contributor

💔 Test failed - status-travis

@torkleyy

Copy link
Copy Markdown
Author

Fixed (it failed because it expected a "filtered out" argument).

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented May 26, 2017

Copy link
Copy Markdown
Contributor

📌 Commit b356af0 has been approved by alexcrichton

@bors

bors commented May 26, 2017

Copy link
Copy Markdown
Contributor

⌛ Testing commit b356af0 with merge 9b856c7...

@bors

bors commented May 26, 2017

Copy link
Copy Markdown
Contributor

💔 Test failed - status-travis

@torkleyy

Copy link
Copy Markdown
Author

Huh? It works for me, even after rebasing onto upstream/master. Anyways, I'll push a fix any moment...

by using with_stderr_contains because
parallel build may mix up the lines.

Additionally, remove the last line of
the benchmark.
@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

Ah yeah I think that's a very recent change on nightly

@bors

bors commented May 27, 2017

Copy link
Copy Markdown
Contributor

📌 Commit dee3c2e has been approved by alexcrichton

@bors

bors commented May 27, 2017

Copy link
Copy Markdown
Contributor

⌛ Testing commit dee3c2e with merge 015897a...

bors added a commit that referenced this pull request May 27, 2017
Add --exclude flag

Allows to exclude packages in conjunction
with --all.

Addresses #2878
@bors

bors commented May 28, 2017

Copy link
Copy Markdown
Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 015897a to master...

@bors
bors merged commit dee3c2e into rust-lang:master May 28, 2017
@torkleyy
torkleyy deleted the exclude branch May 28, 2017 03:10
bors added a commit that referenced this pull request Feb 26, 2018
…hton

Support --exclude option for `cargo doc`

I think this should have been implemented when the feature was added for
other commands. Probably just an oversight.

cc #4031

r? @alexcrichton
@ehuss ehuss added this to the 1.19.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes Release-note worthy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants