Skip to content

Commit 73aa896

Browse files
committed
config
1 parent 4bc9b2c commit 73aa896

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/cli/lookup_test.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def test_config_invalid(tmpdir):
929929

930930
# TODO: test with FILESDIR
931931

932-
@pytest.mark.parametrize("type,file", [("addon", "misra.py"), ("library", "gnu.cfg"), ("platform", "avr8.xml")])
932+
@pytest.mark.parametrize("type,file", [("addon", "misra.py"), ("config", "cppcheck.cfg"), ("library", "gnu.cfg"), ("platform", "avr8.xml")])
933933
def test_lookup_path(tmpdir, type, file):
934934
test_file = os.path.join(tmpdir, 'test.c')
935935
with open(test_file, 'wt'):
@@ -939,7 +939,12 @@ def test_lookup_path(tmpdir, type, file):
939939
path = os.path.dirname(__lookup_cppcheck_exe())
940940
env = os.environ.copy()
941941
env['PATH'] = path + (';' if sys.platform == 'win32' else ':') + env.get('PATH', '')
942-
exitcode, stdout, stderr, _ = cppcheck_ex(args=[f'--debug-lookup={type}', f'--{type}={file}', test_file], cppcheck_exe=cppcheck, cwd=str(tmpdir), env=env)
942+
if type == 'config':
943+
with open(os.path.join(path, "cppcheck.cfg"), 'wt') as f:
944+
f.write('{}')
945+
exitcode, stdout, stderr, _ = cppcheck_ex(args=[f'--debug-lookup={type}', test_file], cppcheck_exe=cppcheck, cwd=str(tmpdir), env=env)
946+
else:
947+
exitcode, stdout, stderr, _ = cppcheck_ex(args=[f'--debug-lookup={type}', f'--{type}={file}', test_file], cppcheck_exe=cppcheck, cwd=str(tmpdir), env=env)
943948
assert exitcode == 0, stdout if stdout else stderr
944949
def format_path(p):
945950
return p.replace('\\', '/').replace('"', '\'')
@@ -956,6 +961,13 @@ def try_success(f):
956961
try_success(os.path.join(path, 'addons', file)),
957962
f'Checking {format_path(test_file)} ...'
958963
]
964+
elif type == 'config':
965+
def try_success(f):
966+
return f"looking for '{format_path(f)}'"
967+
assert lines == [
968+
try_success(os.path.join(path, file)),
969+
f'Checking {format_path(test_file)} ...'
970+
]
959971
elif type == 'platform':
960972
def try_fail(f):
961973
f = format_path(f)

0 commit comments

Comments
 (0)