Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
- exact match for names with glob characters in them
- case sensitivity (`fnmatch.fnmatch` normalises case on Windows)
  • Loading branch information
lilatomic committed Dec 26, 2024
1 parent 4f398fc commit 98449ff
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/python/pants/engine/environment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,23 @@ def test_envvar_fnmatch() -> None:
{
"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"}
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 == {}

0 comments on commit 98449ff

Please sign in to comment.