Skip to content

Ignore empty .cbi/config files #183

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

Merged
merged 2 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions codebasin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def _load_compilers():
log.error(str(e))
return

# Ignore empty configuration files.
if "compiler" not in toml:
return

for name, definition in toml["compiler"].items():
# Check if the user is defining a new compiler.
if name not in _compilers:
Expand Down
10 changes: 10 additions & 0 deletions tests/compilers/test_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ def test_unrecognized(self):

tmp.cleanup()

def test_empty_config(self):
"""Check that we ignore empty configuration files."""
tmp = tempfile.TemporaryDirectory()
path = Path(tmp.name)
os.chdir(tmp.name)
os.mkdir(".cbi")
open(path / ".cbi" / "config", mode="w").close()
config._load_compilers()
tmp.cleanup()


if __name__ == "__main__":
unittest.main()