MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / test_arguments_regression

Function test_arguments_regression

addons/test/misra_test.py:128–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 dump_remove(src)
127
128def test_arguments_regression():
129 args_ok = ["-generate-table",
130 "--rule-texts=./addons/test/assets/misra_rules_multiple_lines.txt",
131 "--verify-rule-texts",
132 "-t=foo", "--template=foo",
133 "--suppress-rules=15.1",
134 "--quiet",
135 "--cli",
136 "--no-summary",
137 "--show-suppressed-rules",
138 "-P=src/", "--file-prefix=src/",
139 "--severity=misra-warning"]
140 # Arguments with expected SystemExit
141 args_exit = ["--non-exists", "--non-exists-param=42", "-h", "--help"]
142
143 from addons.misra import get_args_parser
144
145 # sys.argv contains all pytest arguments - so clear all existing arguments first and restore afterwards
146 sys_argv_old = sys.argv
147 sys.argv = [sys.argv[0]]
148
149 try:
150 for arg in args_exit:
151 sys.argv.append(arg)
152 with pytest.raises(SystemExit):
153 parser = get_args_parser()
154 parser.parse_args()
155 sys.argv.remove(arg)
156
157 for arg in args_ok:
158 sys.argv.append(arg)
159 try:
160 parser = get_args_parser()
161 parser.parse_args()
162 except SystemExit:
163 pytest.fail("Unexpected SystemExit with '%s'" % arg)
164 sys.argv.remove(arg)
165 finally:
166 sys.argv = sys_argv_old
167
168
169def test_read_ctu_info_line(checker):

Callers

nothing calls this directly

Calls 2

get_args_parserFunction · 0.90
failMethod · 0.80

Tested by

no test coverage detected