-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
extra_env_vars support fnmatch globs #21781
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,32 @@ def test_invalid_variable() -> None: | |
"An invalid variable was requested via the --test-extra-env-var mechanism: 3INVALID" | ||
in str(exc) | ||
) | ||
|
||
|
||
def test_envvar_fnmatch() -> None: | ||
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. Could we add a test of the exact-matching behaviour? E.g. include an env variable 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. good catch! |
||
"""Test fnmatch patterns correctly pull in all matching envvars.""" | ||
|
||
pants_env = CompleteEnvironmentVars( | ||
{ | ||
"LETTER_C": "prefix_char_match", | ||
"LETTER_PI": "prefix", | ||
"LETTER_P*": "exact_match_with_glob", | ||
"letter_lower": "case-sensitive", | ||
} | ||
) | ||
|
||
char_match = pants_env.get_subset(["LETTER_?"]) | ||
assert char_match == {"LETTER_C": "prefix_char_match"} | ||
|
||
multichar_match = pants_env.get_subset(["LETTER_*"]) | ||
assert multichar_match == { | ||
"LETTER_C": "prefix_char_match", | ||
"LETTER_PI": "prefix", | ||
"LETTER_P*": "exact_match_with_glob", | ||
} | ||
|
||
exact_match_with_glob = pants_env.get_subset(["LETTER_P*"]) | ||
assert exact_match_with_glob == {"LETTER_P*": "exact_match_with_glob"} | ||
|
||
case_sensitive = pants_env.get_subset(["LETTER_LOWER"]) | ||
assert case_sensitive == {} |
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.
Good idea to factor this repeated text out 👍