Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a

std::vector<std::string> lookupPaths{
Path::getCurrentPath(), // TODO: do we want to look in CWD?
Path::getPathFromFilename(argv[0])
Path::getPathFromFilename(mSettings.exename),
};

bool executorAuto = true;
Expand Down
22 changes: 22 additions & 0 deletions test/cli/lookup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,28 @@ def test_platform_lookup_ext(tmpdir):
]


def test_platform_lookup_path(tmpdir):
Comment thread
danmar marked this conversation as resolved.
test_file = os.path.join(tmpdir, 'test.c')
with open(test_file, 'wt'):
pass

c = 'cppcheck.exe' if sys.platform == 'win32' else 'cppcheck'
Comment thread
danmar marked this conversation as resolved.
Outdated
path = os.path.dirname(__lookup_cppcheck_exe())
env = os.environ.copy()
env['PATH'] = path
exitcode, stdout, stderr, _ = cppcheck_ex(args=['--debug-lookup=platform', '--platform=avr8.xml', test_file], cppcheck_exe=c, cwd=str(tmpdir), env=env)
assert exitcode == 0, stdout if stdout else stderr
lines = stdout.replace('\\', '/').splitlines()
assert lines == [
"looking for platform 'avr8.xml'",
"try to load platform file '{}/avr8.xml' ... Error=XML_ERROR_FILE_NOT_FOUND ErrorID=3 (0x3) Line number=0: filename={}/avr8.xml".format(tmpdir, tmpdir),
"try to load platform file '{}/platforms/avr8.xml' ... Error=XML_ERROR_FILE_NOT_FOUND ErrorID=3 (0x3) Line number=0: filename={}/platforms/avr8.xml".format(tmpdir, tmpdir),
"try to load platform file '{}/avr8.xml' ... Error=XML_ERROR_FILE_NOT_FOUND ErrorID=3 (0x3) Line number=0: filename={}/avr8.xml".format(path, path),
"try to load platform file '{}/platforms/avr8.xml' ... Success".format(path),
'Checking {} ...'.format(test_file)
]


def test_platform_lookup_notfound(tmpdir):
test_file = os.path.join(tmpdir, 'test.c')
with open(test_file, 'wt'):
Expand Down
Loading