def config_make_list_matcher(parse: Callable[[str], T]) -> ConfigMatchCallback[list[T]]:
def config_match_list(match: str, value: list[T]) -> bool:
+ if not match:
+ return len(value) == 0
+
return parse(match) in value
return config_match_list
v = self.expand_specifiers(v, path)
- if not v:
- die("Match value cannot be empty")
-
if s := SETTINGS_LOOKUP_BY_NAME.get(k):
if not s.match:
die(f"{k} cannot be used in [{section}]")
assert config.image_id != "abcde"
+def test_match_empty(tmp_path: Path) -> None:
+ with chdir(tmp_path):
+ Path("mkosi.conf").write_text(
+ """\
+ [Match]
+ Profiles=
+
+ [Build]
+ Environment=ABC=QED
+ """
+ )
+
+ _, [config] = parse_config([])
+
+ assert config.environment.get("ABC") == "QED"
+
+ _, [config] = parse_config(["--profile", "profile"])
+
+ assert config.environment.get("ABC") is None
+
+
@pytest.mark.parametrize("dist1,dist2", itertools.combinations_with_replacement(Distribution, 2))
def test_match_distribution(tmp_path: Path, dist1: Distribution, dist2: Distribution) -> None:
with chdir(tmp_path):