Skip to content

Commit 3943e9e

Browse files
committed
improve testing
1 parent 4ed0b8d commit 3943e9e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/cli/other_test.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3947,7 +3947,7 @@ def test_simplecpp_syntax_error(tmp_path):
39473947
# TODO: lacks column information
39483948
'{}:1:0: error: No header in #include [syntaxError]'.format(test_file),
39493949
'{}:1:0: error: No header in #include [syntaxError]'.format(test_file)
3950-
3950+
]
39513951

39523952
def test_max_configs(tmp_path):
39533953
test_file = tmp_path / 'test.cpp'
@@ -3957,18 +3957,25 @@ def test_max_configs(tmp_path):
39573957
f.write(f'#{dir} defined(X{i})\nx = {i};\n')
39583958
f.write('#endif\n')
39593959

3960-
# default max configs is set to 12
3961-
_, stdout, stderr = cppcheck(['-v', '--enable=information', '--template=daca2', str(test_file)])
3960+
args = ['--enable=information', '--template=daca2', str(test_file)]
3961+
3962+
# default max configs is set to 12, warn if code contains more configurations than that
3963+
_, stdout, stderr = cppcheck(args)
39623964
assert stderr.splitlines() == [
39633965
'{}:0:0: information: Too many #ifdef configurations - cppcheck only checks 12 of 20 configurations. Use --force to check all configurations. [toomanyconfigs]'.format(test_file)
39643966
]
39653967

39663968
# set explicit max configs => do not warn
3967-
_, _, stderr = cppcheck(['--enable=information', '--template=daca2', '--max-configs=6', str(test_file)])
3969+
# configurations are likely skipped by intention
3970+
_, _, stderr = cppcheck(['--max-configs=6'] + args)
39683971
assert stderr.splitlines() == []
39693972

3970-
# when using --check-configs, warn
3971-
_, _, stderr = cppcheck(['--check-config', '--template=daca2', '--max-configs=6', str(test_file)])
3973+
# when using --check-configs, warn if code contains more than max configs
3974+
_, _, stderr = cppcheck(['--check-config', '--max-configs=6'] + args)
39723975
assert stderr.splitlines() == [
39733976
'{}:0:0: information: Too many #ifdef configurations - cppcheck only checks 6 of 20 configurations. Use --force to check all configurations. [toomanyconfigs]'.format(test_file)
39743977
]
3978+
3979+
# when using --check-configs, do not warn if code contains less than max configs
3980+
_, _, stderr = cppcheck(['--check-config', '--max-configs=60'] + args)
3981+
assert stderr.splitlines() == []

0 commit comments

Comments
 (0)