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

Function __test_clang_tidy

test/cli/other_test.py:3432–3459  ·  view source on GitHub ↗
(tmpdir, use_compdb)

Source from the content-addressed store, hash-verified

3430 assert stderr.splitlines() == [] # no error since the unused templates are not being checked
3431
3432def __test_clang_tidy(tmpdir, use_compdb):
3433 test_file = os.path.join(tmpdir, 'test.cpp')
3434 with open(test_file, 'wt') as f:
3435 f.write(
3436"""static void foo() // NOLINT(misc-use-anonymous-namespace)
3437{
3438 (void)(*((int*)nullptr));
3439}""")
3440
3441 project_file = __write_compdb(tmpdir, test_file) if use_compdb else None
3442
3443 args = [
3444 '-q',
3445 '--template=simple',
3446 '--clang-tidy'
3447 ]
3448 if project_file:
3449 args += ['--project={}'.format(project_file)]
3450 else:
3451 args += [str(test_file)]
3452 exitcode, stdout, stderr = cppcheck(args)
3453 assert exitcode == 0, stdout
3454 assert stdout.splitlines() == [
3455 ]
3456 assert stderr.splitlines() == [
3457 '{}:3:14: error: Null pointer dereference: (int*)nullptr [nullPointer]'.format(test_file),
3458 '{}:3:14: style: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [clang-tidy-google-readability-casting]'.format(test_file)
3459 ]
3460
3461
3462@pytest.mark.skipif(not __has_clang_tidy, reason='clang-tidy is not available')

Callers 2

test_clang_tidyFunction · 0.85
test_clang_tidy_projectFunction · 0.85

Calls 6

cppcheckFunction · 0.90
__write_compdbFunction · 0.85
strFunction · 0.85
formatMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected