From f86b230f2e9748c63cb83a86ca2bf6b00d77b398 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 1 Sep 2024 14:15:12 +0300 Subject: [PATCH] test: handle clang diagnostics returning None for filename The parser may return None for clang diagnostics filename if there isn't one. Handle it gracefully. --- test/test_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_parser.py b/test/test_parser.py index da630ea8..f99a5e26 100755 --- a/test/test_parser.py +++ b/test/test_parser.py @@ -81,7 +81,8 @@ def get_output(self): roots[key] = root for error in errors: - errors_str += f'{error.level.name}: {os.path.basename(error.filename)}:{error.line}: {error.message}\n' # noqa: E501 + filename = os.path.basename(error.filename) if error.filename else '' + errors_str += f'{error.level.name}: {filename}:{error.line}: {error.message}\n' # noqa: E501 for directive in self.directives: filename = directive.get_input_filename()