From a1f3c707e942608e449ddf0e898fa78947d14661 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Mon, 7 Apr 2025 15:00:14 +0100 Subject: [PATCH 1/2] Add regression test for empty .cbi/config file Signed-off-by: John Pennycook --- tests/compilers/test_compilers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/compilers/test_compilers.py b/tests/compilers/test_compilers.py index 0d05cb9..a0694e4 100644 --- a/tests/compilers/test_compilers.py +++ b/tests/compilers/test_compilers.py @@ -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() From be59a349a8ae15e4466a595ef466e3f73f34ca58 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Mon, 7 Apr 2025 15:49:08 +0100 Subject: [PATCH 2/2] Ignore empty .cbi/config files Signed-off-by: John Pennycook --- codebasin/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codebasin/config.py b/codebasin/config.py index f7aca83..c949ed8 100644 --- a/codebasin/config.py +++ b/codebasin/config.py @@ -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: