mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 00:15:05 +00:00
fix: handle empty projects config key
This commit is contained in:
2 files changed
+15
-1
No files matched your search
@@ -871,7 +871,7 @@ class SerenaConfig(SharedConfig, ModeSelectionDefinitionWithBaseModes):
|
||||
if "projects" not in loaded_commented_yaml:
|
||||
raise SerenaConfigError("`projects` key not found in Serena configuration. Please update your `serena_config.yml` file.")
|
||||
instance.projects = []
|
||||
for path in loaded_commented_yaml["projects"]:
|
||||
for path in loaded_commented_yaml["projects"] or []:
|
||||
path = Path(path).resolve()
|
||||
try:
|
||||
path_exists = path.exists()
|
||||
|
||||
@@ -523,6 +523,20 @@ class TestSerenaConfigFromConfigFileRobustness:
|
||||
body_lines.append(f" - {p}")
|
||||
self.master_config_path.write_text("\n".join(body_lines) + "\n")
|
||||
|
||||
def test_empty_projects_key_is_treated_as_empty_list(self, monkeypatch):
|
||||
"""A bare ``projects:`` key should not abort config loading."""
|
||||
self.master_config_path.write_text("projects:\n")
|
||||
|
||||
monkeypatch.setattr(
|
||||
SerenaConfig,
|
||||
"_determine_config_file_path",
|
||||
classmethod(lambda cls: str(self.master_config_path)),
|
||||
)
|
||||
|
||||
config = SerenaConfig.from_config_file(generate_if_missing=False)
|
||||
|
||||
assert config.projects == []
|
||||
|
||||
def test_malformed_project_is_skipped_with_warning(self, caplog, monkeypatch):
|
||||
"""A malformed project.yml must not abort loading of the others."""
|
||||
good_project = self._make_project_dir(
|
||||
|
||||
Reference in new issue
Block a user