Skip to content

Commit

Permalink
Do not allow parse if the <report dir> does not exist
Browse files Browse the repository at this point in the history
This change prevents the CodeChecker parse command
from running if the entered report dir or filepath
parameter does not exist.
Up until now, the parse command ran with any parameters,
reporting zero findings if a wrong parameter was entered.
Fixes #4186
  • Loading branch information
Nora Zinaeddin committed Apr 25, 2024
1 parent bc7bf7c commit 8480c51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions analyzer/codechecker_analyzer/cmd/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ def main(args):
LOG.error(fnerr)
sys.exit(1)

incorrect_input_paths = [input_path for input_path in args.input
if not os.path.exists(input_path)]

if incorrect_input_paths:
for input_path in incorrect_input_paths:
LOG.error(f"Input path {input_path} does not exist!")
sys.exit(1)

export = args.export if 'export' in args else None
if export == 'html' and 'output_path' not in args:
LOG.error("Argument --export not allowed without argument --output "
Expand Down
11 changes: 11 additions & 0 deletions analyzer/tests/functional/cmdline/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ def test_analyzer_config(self):
self.assertTrue(desc)
self.assertFalse(desc[0].islower())

def test_parse_incorrect_file_path(self):
"""
This test checks whether the parse command stops running if a
non-existent path is specified.
"""

parse_cmd = [env.codechecker_cmd(), 'parse', '/asd/123/qwe']

self.assertIn('Input path /asd/123/qwe does not exist!',
run_cmd(parse_cmd)[1])

def test_checker_config_format(self):
"""
Test if checker config option is meeting the reqired format.
Expand Down

0 comments on commit 8480c51

Please sign in to comment.