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

Function test_addon_namingng_config

test/cli/other_test.py:687–768  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

685
686# TODO: test with -j2
687def test_addon_namingng_config(tmpdir):
688 addon_file = os.path.join(tmpdir, 'namingng.json')
689 addon_config_file = os.path.join(tmpdir, 'namingng.config.json')
690 with open(addon_file, 'wt') as f:
691 f.write("""
692{
693 "script": "addons/namingng.py",
694 "args": [
695 "--configfile=%s"
696 ]
697}
698 """%(addon_config_file).replace('\\','\\\\'))
699
700 with open(addon_config_file, 'wt') as f:
701 f.write("""
702{
703 "RE_FILE": "[^/]*[a-z][a-z0-9_]*[a-z0-9]\\.c\\Z",
704 "RE_NAMESPACE": false,
705 "RE_VARNAME": ["+bad pattern","[a-z]_good_pattern\\Z","(parentheses?"],
706 "RE_PRIVATE_MEMBER_VARIABLE": "[a-z][a-z0-9_]*[a-z0-9]\\Z",
707 "RE_PUBLIC_MEMBER_VARIABLE": {
708 "tmp_.*\\Z":[true,"illegal prefix tmp_"],
709 "bad_.*\\Z":true,
710 "public_.*\\Z":[false],
711 "pub_.*\\Z":[0,"required prefix pub_ missing"]
712 },
713 "RE_GLOBAL_VARNAME": "[a-z][a-z0-9_]*[a-z0-9]\\Z",
714 "RE_FUNCTIONNAME": "[a-z][a-z0-9_]*[a-z0-9]\\Z",
715 "RE_CLASS_NAME": "[a-z][a-z0-9_]*[a-z0-9]\\Z",
716 "_comment1": "these should all be arrays, or null, or not set",
717
718 "include_guard": true,
719 "var_prefixes": ["bad"],
720 "function_prefixes": false,
721 "_comment2": "these should all be dict",
722
723 "skip_one_char_variables": "false",
724 "_comment3": "this should be bool",
725
726 "RE_VAR_NAME": "typo"
727}
728 """.replace('\\','\\\\'))
729
730 test_file_basename = 'test.c'
731 test_file = os.path.join(tmpdir, test_file_basename)
732 with open(test_file, 'a'):
733 # only create the file
734 pass
735
736 args = ['--addon='+addon_file, '--verbose', '--enable=all', '-j1', test_file]
737
738 exitcode, stdout, stderr = cppcheck(args)
739 assert exitcode == 0, stdout if stdout else stderr
740
741 lines = __remove_verbose_log(stdout.splitlines())
742 assert lines == [
743 'Checking {} ...'.format(test_file)
744 ]

Callers

nothing calls this directly

Calls 6

cppcheckFunction · 0.90
__remove_verbose_logFunction · 0.85
formatMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected