Skip to content

Commit ce7b16c

Browse files
authored
Merge pull request #183 from Pennycook/bugfix/empty-config
Ignore empty .cbi/config files
2 parents 32029a6 + be59a34 commit ce7b16c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

codebasin/config.py

+4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ def _load_compilers():
198198
log.error(str(e))
199199
return
200200

201+
# Ignore empty configuration files.
202+
if "compiler" not in toml:
203+
return
204+
201205
for name, definition in toml["compiler"].items():
202206
# Check if the user is defining a new compiler.
203207
if name not in _compilers:

tests/compilers/test_compilers.py

+10
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,16 @@ def test_unrecognized(self):
422422

423423
tmp.cleanup()
424424

425+
def test_empty_config(self):
426+
"""Check that we ignore empty configuration files."""
427+
tmp = tempfile.TemporaryDirectory()
428+
path = Path(tmp.name)
429+
os.chdir(tmp.name)
430+
os.mkdir(".cbi")
431+
open(path / ".cbi" / "config", mode="w").close()
432+
config._load_compilers()
433+
tmp.cleanup()
434+
425435

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

0 commit comments

Comments
 (0)