-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add --manifest-path and --features #2085
Conversation
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 for fixing the issue with the manifest flags.
@@ -273,6 +266,51 @@ impl KaniArgs { | |||
} | |||
} | |||
|
|||
/// Arguments that Kani pass down into Cargo essentially uninterpreted. | |||
/// These generally have to do with selection of packages or activation of features. | |||
/// These do not (currently) include cargo args that kani pays special attention to: |
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.
maybe say "these should not include"
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.
Should it? I wasn't sure. I didn't want to make too strong of a statement if we decide otherwise later except someone sees this comment and wonders "well, why not?"...
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.
- I think if we decide the other way around, we can always update the comments. I don't think writing it here is a one-way door. But I do think that this leaves space for inconsistency.
- I do think it would be odd to have a cargo argument being called as part of standalone kani flow. If we want to move stuff here, I would expect a counter part StandaloneArgs that basically duplicate the things that are relevant to both.
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.
I think you misunderstood the comment? It's not about kani
vs cargo-kani
, it's about cargo args that kani is interpreting (hence the examples like --target-dir
) versus those that we just kinda pass down.
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.
ok, I literally just said "kani is interpreting" again, which was maybe the confusion (between kani-the-project, and kani-the-binary)
"It's about cargo args that we are interpreting... versus those that we just pass down"
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.
I was actually wondering if this should be part of CargoKaniArgs
instead of KaniArgs
? None of these flags make sense in the standalone version, right?
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.
Correct, but this PR doesn't change that yet. There's more extensive work needed (e.g. in how arguments get plumbed through the session) to do that.
/// Do not activate the `default` feature | ||
#[arg(long)] | ||
pub no_default_features: bool, | ||
// This tolerates spaces too, but we say "comma" only because this is the least error-prone approach... |
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.
why can't we use: https://docs.rs/clap/4.0.32/clap/struct.Arg.html#method.value_delimiter?
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.
I don't think that supports multiple delimiters?
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.
But why do you want to support multiple delimeters? Don't we want to only support comma or multiple usage of the same argument?
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.
well, cargo says it does?
cargo build --help
...
-F, --features <FEATURES> Space or comma separated list of features to activate
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.
I see. You want to keep the same format as cargo. We should probably document the exact behavior in this case. Maybe say that comma is preferred.
Note that clap mentions that we shouldn't really be accepting options with multiple arguments and positional arguments:
A common mistake is to define an option which allows multiple values and a positional argument.
from: https://docs.rs/clap/4.0.32/clap/builder/struct.Arg.html#examples-20
I was wondering if explicitly setting the separator to ',' would fix this issue, but clap seems to just join all the space separated arguments into one. 🤦♀️
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.
Maybe say that comma is preferred
I already set our help text to just say comma, since I thought spaces was an odd choice.
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.
BTW, if you want to match the cargo behavior, I believe you should set the action to append.
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.
?? There's a test below showing it behaving how I expect?
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.
Cool. From reading the docs I thought that Set was the default
@@ -66,9 +60,20 @@ impl KaniSession { | |||
let rustc_args = self.kani_rustc_flags(); | |||
|
|||
let mut cargo_args: Vec<OsString> = vec!["rustc".into()]; | |||
if self.args.all_features { | |||
if let Some(path) = &self.args.cargo.manifest_path { |
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.
Any chance this can be auto generated? So we don't need to change two files whenever we just want to pass down the arguments?
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.
I didn't see any way to reverse the parsed args back into a vector, if that's what you mean. (I agree it'd be nice.)
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.
I think at least creating a method that converts them might be nice. Not a blocker though.
|
||
let harness_none = mock_proof_harness("check_one", None, None); | ||
let harness_some = mock_proof_harness("check_one", Some(3), None); | ||
|
||
fn resolve(args: &[&str], harness: &HarnessMetadata) -> Option<u32> { |
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.
Not for this PR, but I was wondering if we could stop calling the parser as part of these unit tests.
6a1dfe8
to
42929fd
Compare
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.
My other comments are nice to have, not blockers.
Description of changes:
parse_from
callsexit
on failure, so fix all tests to usetry_parse_from().unwrap()
(to panic instead of exit), otherwise the test suite runner can't handle failure properly.Parser
, some are justSubcommand
orArgs
--manifest-path
requires more scripty tests. Compiletest mode for executing arbitrary commands #2059 continues to be a need :(Resolved issues:
Resolves #1420
Resolves #1979
Call-outs:
Testing:
How is this change tested?
Is this a refactor change?
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.