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

#1682: fix help tests #1734

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

#1682: fix help tests #1734

wants to merge 5 commits into from

Conversation

Ifropc
Copy link
Contributor

@Ifropc Ifropc commented Nov 18, 2024

Part of #1682

In this PR help tests are fixed.
As part of the change, I re-organized build_host_function_parameters to return either previous result or help message. All callers up the stack now respect this behavior.

Why

Previously, we were using clap's get_matches_from that exits with code 0 (printing help message). This made our tests exit with code 0 as well (when calling --help).
As part of the change we handle DisplayError returning help message, and keeping existing behavior for all other clap errors.

Known limitations

Some of the tests are now failing in CI. They were previously effectively ignored, as the whole suite was exiting as soon as help tests were running.
This tests are fixed in other PRs (see #1682 )

@leighmcculloch
Copy link
Member

This tests are fixed in other PRs (see #1682 )

What needs to merge before this PR can be merged?

@Ifropc
Copy link
Contributor Author

Ifropc commented Nov 26, 2024

@leighmcculloch we can either merge all listed PRs at the same time or merge all of them here first

@elizabethengelman
Copy link
Contributor

This is looking great! Thanks for digging into it - it was driving me crazy ;p

we can either merge all listed PRs at the same time or merge all of them here first

W/r/t when to merge this and the other PRs, i like the idea of merging those test fixing into this PR first.

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Thanks for figuring out why these tests were preventing from running. Great find and learning for us all.

For the solution, I'd like us to reconsider the approach here, see the inline comment. Please lmk if there's a reason we can't do the error approach.

cmd/soroban-cli/src/commands/contract/invoke.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/commands/contract/arg_parsing.rs Outdated Show resolved Hide resolved
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

One ask, otherwise this looks good, very easy to follow.

}
},
Err(ArgParse(HelpMessage(help))) => {
println!("{help}");
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 we need to do this at the top level, rather than inside the arg parsing, otherwise the exit codes will be incorrect when generating the help when no --help is passed. It's a small thing, but also I believe a small fix to keep passing the error as is up the chain, and at the top level doing as you do here.

Comment on lines +145 to 147
Err(ArgParsing(HelpMessage(help))) => {
println!("{help}");
}
Copy link
Member

Choose a reason for hiding this comment

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

Same comment about doing this at the top level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

3 participants