Skip to content

Commit 4bc9b2c

Browse files
committed
add addon test
1 parent 3e0b256 commit 4bc9b2c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test/cli/lookup_test.py

Lines changed: 14 additions & 5 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", [("library", "gnu.cfg"), ("platform", "avr8.xml")])
932+
@pytest.mark.parametrize("type,file", [("addon", "misra.py"), ("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'):
@@ -938,16 +938,25 @@ def test_lookup_path(tmpdir, type, file):
938938
cppcheck = 'cppcheck' # No path
939939
path = os.path.dirname(__lookup_cppcheck_exe())
940940
env = os.environ.copy()
941-
env['PATH'] = path
941+
env['PATH'] = path + (';' if sys.platform == 'win32' else ':') + env.get('PATH', '')
942942
exitcode, stdout, stderr, _ = cppcheck_ex(args=[f'--debug-lookup={type}', f'--{type}={file}', test_file], cppcheck_exe=cppcheck, cwd=str(tmpdir), env=env)
943943
assert exitcode == 0, stdout if stdout else stderr
944944
def format_path(p):
945945
return p.replace('\\', '/').replace('"', '\'')
946946
lines = format_path(stdout).splitlines()
947947

948-
# TODO make lookups consistent between library and platform and add --debug-lookup={type} option
949-
950-
if type == 'platform':
948+
if type == 'addon':
949+
def try_fail(f):
950+
return f"looking for {type} '{format_path(f)}'"
951+
def try_success(f):
952+
return f"looking for {type} '{format_path(f)}'"
953+
assert lines == [
954+
f"looking for {type} '{file}'",
955+
try_fail(os.path.join(path, file)),
956+
try_success(os.path.join(path, 'addons', file)),
957+
f'Checking {format_path(test_file)} ...'
958+
]
959+
elif type == 'platform':
951960
def try_fail(f):
952961
f = format_path(f)
953962
return f"try to load {type} file '{f}' ... Error=XML_ERROR_FILE_NOT_FOUND ErrorID=3 (0x3) Line number=0: filename={f}"

0 commit comments

Comments
 (0)