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

Function test_clang_tidy_error_exit

test/cli/other_test.py:3474–3508  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

3472
3473@pytest.mark.skipif(not __has_clang_tidy, reason='clang-tidy is not available')
3474def test_clang_tidy_error_exit(tmp_path): # #13828 / #13829
3475 test_file = tmp_path / 'test.cpp'
3476 with open(test_file, 'wt') as f:
3477 f.write(
3478"""#include <string>
3479#include <utility>
3480
3481// cppcheck-suppress clang-tidy-modernize-use-trailing-return-type
3482static bool f() // NOLINT(misc-use-anonymous-namespace)
3483{
3484 std::string str;
3485 const std::string str1 = std::move(str);
3486 (void)str1;
3487 return str.empty();
3488}""")
3489
3490 # TODO: remove project file usage when --clang-tidy works with non-project files
3491 project_file = __write_compdb(tmp_path, str(test_file))
3492
3493 args = [
3494 '-q',
3495 '--template=simple',
3496 '--inline-suppr',
3497 '--std=c++11',
3498 '--clang-tidy',
3499 '--project={}'.format(project_file)
3500 ]
3501
3502 exitcode, stdout, stderr = cppcheck(args)
3503 assert stdout.splitlines() == []
3504 assert stderr.splitlines() == [
3505 "{}:10:12: warning: 'str' used after it was moved [clang-tidy-bugprone-use-after-move]".format(test_file),
3506 "{}:10:12: style: 'str' used after it was moved [clang-tidy-hicpp-invalid-access-moved]".format(test_file)
3507 ]
3508 assert exitcode == 0, stdout
3509
3510
3511def test_suppress_unmatched_wildcard(tmp_path): # #13660

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected