File: suppress-syntaxError_test.py

package info (click to toggle)
cppcheck 2.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,132 kB
  • sloc: cpp: 268,935; python: 20,890; ansic: 8,090; sh: 1,045; makefile: 1,008; xml: 1,005; cs: 291
file content (31 lines) | stat: -rw-r--r-- 1,336 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# python -m pytest test-suppress-syntaxError.py

import os
from testutils import cppcheck

__script_dir = os.path.dirname(os.path.abspath(__file__))

def test_j():
    ret, stdout, stderr = cppcheck(['-q', '--error-exitcode=1', '-j2', '-q', 'proj-suppress-syntaxError'], cwd=__script_dir)
    assert ret == 1, stdout
    assert len(stderr) > 0

def test_suppress_j():
    ret, stdout, stderr = cppcheck(['-q', '--error-exitcode=1', '--suppress=*:proj-suppress-syntaxError/*', '-j2', '-q', 'proj-suppress-syntaxError'], cwd=__script_dir)
    assert ret == 0, stdout
    assert len(stderr) == 0

# TODO: test with -j2
def test_safety_suppress_syntax_error_implicitly(tmpdir):
    ret, stdout, stderr = cppcheck(['-q', '--safety', '--suppress=*', 'proj-suppress-syntaxError', '-j1'], remove_checkers_report=False, cwd=__script_dir)
    assert ret == 1, stdout
    assert '[syntaxError]' in stderr
    assert 'Active checkers: There was critical errors' in stderr

# TODO: test with -j2
def test_safety_suppress_syntax_error_explicitly():
    ret, stdout, stderr = cppcheck(['-q', '--safety', '--suppress=syntaxError', 'proj-suppress-syntaxError', '-j1'], remove_checkers_report=False, cwd=__script_dir)
    assert ret == 1, stdout
    assert '[syntaxError]' not in stderr
    assert 'Active checkers: There was critical errors' in stderr