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

agave-validator: add args tests for set-log-filter #4923

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yihau
Copy link
Member

@yihau yihau commented Feb 11, 2025

Problem

#4082

Summary of Changes

extracting args parsing logic and adding tests

@yihau yihau mentioned this pull request Feb 11, 2025
@yihau yihau marked this pull request as draft February 14, 2025 12:18
@yihau yihau force-pushed the add-set-log-filter-test branch from f7934ad to bba1eb9 Compare February 14, 2025 12:49
@yihau yihau marked this pull request as ready for review February 14, 2025 12:49
@yihau
Copy link
Member Author

yihau commented Feb 14, 2025

we used let filter = value_t_or_exit!(matches, "filter", String); which exits if filter isn't present. it makes the test become tricky. I change it to matches.value_of("filter").map(|s| s.to_string()) and moved the exit logic to the fn execute as a workaround. this shouldn't affect the original use case and also allows us to add tests to ensure the process works correctly. my plan is to build all tests first, giving us more confidence to proceed with deeper refactoring or upgrading to clap v3/v4 directly.

@steviez
Copy link

steviez commented Feb 14, 2025

we used let filter = value_t_or_exit!(matches, "filter", String); which exits if filter isn't present. it makes the test become tricky. I change it to matches.value_of("filter").map(|s| s.to_string()) and moved the exit logic to the fn execute as a workaround. this shouldn't affect the original use case and also allows us to add tests to ensure the process works correctly. my plan is to build all tests first, giving us more confidence to proceed with deeper refactoring or upgrading to clap v3/v4 directly.

I'm not sure I like this change. Namely, I don't think we should be making the "production" case more convoluted for the "test" case.

As an alternative, I think we could use value_t!() instead of value_t_or_exit!(). This means the parse function can now return a Result, and then we can handle the result above.

I think this format will absolutely be necessary when it comes time to port the run command over

@yihau yihau force-pushed the add-set-log-filter-test branch from 6127b39 to 5dcac19 Compare March 1, 2025 14:15
@yihau
Copy link
Member Author

yihau commented Mar 3, 2025

it's ready for another review! for now it's using value_t and map err.

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

Successfully merging this pull request may close these issues.

2 participants