Skip to content

Commit

Permalink
[fix][cmd] Fix empty CodeChecker invocation
Browse files Browse the repository at this point in the history
CodeChecker will throw the following exception when no subcommand is
given for the CodeChecker command:
```
Traceback (most recent call last):
  File "/cc_bin/CodeChecker.py", line 127, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'
```

This patch will fix this problem and print the help message instead of
this exception.
  • Loading branch information
csordasmarton committed Mar 9, 2020
1 parent 067f0ad commit 2fad73a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions analyzer/tests/functional/cmdline/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def setUp(self):
# Get the CodeChecker cmd if needed for the tests.
self._codechecker_cmd = env.codechecker_cmd()

def test_no_subcommand(self):
""" Call CodeChecker without subcommand. """

main_cmd = [env.codechecker_cmd()]
self.assertEqual(0, run_cmd(main_cmd)[0])

def test_version_help(self):
""" Test the 'analyzer-version' subcommand. """

Expand Down
5 changes: 4 additions & 1 deletion bin/CodeChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def signal_handler(signum, frame):
sys.argv.extend(cfg_args)
args = parser.parse_args()

args.func(args)
try:
args.func(args)
except AttributeError:
parser.print_help()

except KeyboardInterrupt as kb_err:
print(str(kb_err))
Expand Down

0 comments on commit 2fad73a

Please sign in to comment.