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 11, 2024
1 parent bc7bf7c commit d2f2b0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions analyzer/codechecker_analyzer/cmd/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def main(args):
LOG.error(fnerr)
sys.exit(1)

for input_path in args.input:
if not os.path.exists(input_path):
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
10 changes: 10 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,16 @@ 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.assertEqual(1, run_cmd(parse_cmd)[0])

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

0 comments on commit d2f2b0f

Please sign in to comment.