diff --git a/analyzer/codechecker_analyzer/cmd/parse.py b/analyzer/codechecker_analyzer/cmd/parse.py index 64c6e35353..5cdfceec51 100644 --- a/analyzer/codechecker_analyzer/cmd/parse.py +++ b/analyzer/codechecker_analyzer/cmd/parse.py @@ -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 " diff --git a/analyzer/tests/functional/cmdline/test_cmdline.py b/analyzer/tests/functional/cmdline/test_cmdline.py index a3408dd131..d874b2381f 100644 --- a/analyzer/tests/functional/cmdline/test_cmdline.py +++ b/analyzer/tests/functional/cmdline/test_cmdline.py @@ -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.