| 41 | |
| 42 | |
| 43 | def test_show_all_defines(tmp_path): |
| 44 | test_file = tmp_path / 'test.cpp' |
| 45 | with open(test_file, 'wt') as f: |
| 46 | f.write(""" |
| 47 | #define DEF_1 |
| 48 | |
| 49 | void f() |
| 50 | { |
| 51 | } |
| 52 | """) |
| 53 | |
| 54 | rule_file = os.path.join(__rules_dir, 'show-all-defines.rule') |
| 55 | args = [ |
| 56 | '--template=simple', |
| 57 | '-DDEF_2', |
| 58 | '--rule-file={}'.format(rule_file), |
| 59 | str(test_file) |
| 60 | ] |
| 61 | ret, stdout, stderr = cppcheck(args) |
| 62 | assert ret == 0 |
| 63 | assert stdout.splitlines() == [ |
| 64 | 'Checking {} ...'.format(test_file), |
| 65 | 'Processing rule: .*', |
| 66 | 'Checking {}: DEF_2=1...'.format(test_file) |
| 67 | ] |
| 68 | if sys.platform == 'win32': |
| 69 | test_file = str(test_file).replace('\\', '/') |
| 70 | assert stderr.splitlines() == [ |
| 71 | # TODO: this message looks strange |
| 72 | ":1:0: information: found ' # line 2 \"{}\" # define DEF_1' [showalldefines]".format(test_file) |
| 73 | ] |
| 74 | |
| 75 | |
| 76 | def test_stl(tmp_path): |