-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: add harness field to cargo metadata output
#17088
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
Open
ceronman
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
ceronman:add-harness-to-metadata
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,7 +127,12 @@ structure: | |
| "doctest": true | ||
| /* Whether or not this target should be built and run with `--test` | ||
| */ | ||
| "test": true | ||
| "test": true, | ||
| /* Whether or not the target uses the libtest harness. | ||
| Corresponds to the `harness` field in `Cargo.toml`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Raised a higher level concern at #11846 (comment) |
||
| This property is not included if `harness` is true (the default). | ||
| */ | ||
| "harness": false | ||
| }, | ||
| /* The message emitted by the compiler. | ||
|
|
||
|
|
@@ -167,7 +172,8 @@ following structure: | |
| "edition": "2018", | ||
| "doc": true, | ||
| "doctest": true, | ||
| "test": true | ||
| "test": true, | ||
| "harness": false | ||
| }, | ||
| /* The profile indicates which compiler settings were used. */ | ||
| "profile": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we wrote
cargo metadata, we adopted a policy to omit defaults, see https://doc.crates.io/contrib/implementation/schemas.html#schema-designHowever, the question becomes how do we deal with the lack of the field vs the default?
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing that detail from the guidelines. I'll add
skip_serializing_ifhere.I'm not sure exactly what you mean here. In RustRover we can easily assume that no value means true. Or do you mean something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unresolved this because of the open question.
If we always provide
harness, then we have three states:true,false, and "unknown". The last one is relevant when using an old version of Cargo. If we skip on default (would it be a true? false?) then a caller can't differentiate it from "unknown".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I understand now :). Dealing with "unknown" is unavoidable, at least for a while, because older versions of cargo won't have this field. The problem is that now there is some ambiguity: a value not present might be either
trueorunknowndepending on the version of cargo.For us it would be slightly better if the default was not skipped. In that way, our logic will be something like: if
harnessis not there, fallback to try to get it fromCargo.toml. If we skip the default value, our logic will be: ifharnessis not there an cargo version > x it's true otherwise fallback.So we can manage both ways. I understand the spirit of the guidelines and the fact that extra data means extra parsing time and this can affect certain tools. But from my perspective the ambiguity introduced is worse. So I would prefer if we don't skip.