CI; Fixed problems in windows paths

This commit is contained in:
Daniel Marjamäki 2021-06-12 12:45:31 +02:00
parent 4a4808e0ff
commit 83d406806f
3 changed files with 17 additions and 27 deletions

View File

@ -1251,7 +1251,7 @@ void ImportProject::setRelativePaths(const std::string &filename)
{ {
if (Path::isAbsolute(filename)) if (Path::isAbsolute(filename))
return; return;
const std::vector<std::string> basePaths{Path::getCurrentPath()}; const std::vector<std::string> basePaths{Path::fromNativeSeparators(Path::getCurrentPath())};
for (auto &fs: fileSettings) { for (auto &fs: fileSettings) {
fs.filename = Path::getRelativePath(fs.filename, basePaths); fs.filename = Path::getRelativePath(fs.filename, basePaths);
for (auto &includePath: fs.includePaths) for (auto &includePath: fs.includePaths)

View File

@ -20,8 +20,8 @@ def realpath(s):
def create_compile_commands(): def create_compile_commands():
j = [{'directory': realpath('proj2/a'), 'command': 'gcc -c a.c', 'file': 'a.c'}, j = [{'directory': realpath('proj2/a'), 'command': 'gcc -c a.c', 'file': 'a.c'},
{'directory': realpath('proj2'), 'command': 'gcc -c b/b.c', 'file': 'b/b.c'}] {'directory': realpath('proj2'), 'command': 'gcc -c b/b.c', 'file': 'b/b.c'}]
f = open('proj2/' + COMPILE_COMMANDS_JSON, 'wt') with open('proj2/' + COMPILE_COMMANDS_JSON, 'wt') as f:
f.write(json.dumps(j)) f.write(json.dumps(j))
# Run Cppcheck from project path # Run Cppcheck from project path
def cppcheck_local(args): def cppcheck_local(args):
@ -44,8 +44,8 @@ def test_file_filter():
def test_local_path(): def test_local_path():
create_compile_commands() create_compile_commands()
ret, stdout, stderr = cppcheck_local(['--project=compile_commands.json']) ret, stdout, stderr = cppcheck_local(['--project=compile_commands.json'])
file1 = 'a/a.c' file1 = os.path.join('a', 'a.c')
file2 = 'b/b.c' file2 = os.path.join('b', 'b.c')
assert ret == 0, stdout assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 0 assert stdout.find('Checking %s ...' % file1) >= 0
assert stdout.find('Checking %s ...' % file2) >= 0 assert stdout.find('Checking %s ...' % file2) >= 0
@ -65,8 +65,8 @@ def test_local_path_maxconfigs():
def test_relative_path(): def test_relative_path():
create_compile_commands() create_compile_commands()
ret, stdout, stderr = cppcheck(['--project=proj2/' + COMPILE_COMMANDS_JSON]) ret, stdout, stderr = cppcheck(['--project=proj2/' + COMPILE_COMMANDS_JSON])
file1 = 'proj2/a/a.c' file1 = os.path.join('proj2', 'a', 'a.c')
file2 = 'proj2/b/b.c' file2 = os.path.join('proj2', 'b', 'b.c')
assert ret == 0, stdout assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 0 assert stdout.find('Checking %s ...' % file1) >= 0
assert stdout.find('Checking %s ...' % file2) >= 0 assert stdout.find('Checking %s ...' % file2) >= 0
@ -83,8 +83,8 @@ def test_absolute_path():
def test_gui_project_loads_compile_commands_1(): def test_gui_project_loads_compile_commands_1():
create_compile_commands() create_compile_commands()
ret, stdout, stderr = cppcheck(['--project=proj2/proj2.cppcheck']) ret, stdout, stderr = cppcheck(['--project=proj2/proj2.cppcheck'])
file1 = 'proj2/a/a.c' file1 = os.path.join('proj2', 'a', 'a.c')
file2 = 'proj2/b/b.c' file2 = os.path.join('proj2', 'b', 'b.c')
assert ret == 0, stdout assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 0 assert stdout.find('Checking %s ...' % file1) >= 0
assert stdout.find('Checking %s ...' % file2) >= 0 assert stdout.find('Checking %s ...' % file2) >= 0
@ -96,8 +96,8 @@ def test_gui_project_loads_compile_commands_2():
import_project='compile_commands.json', import_project='compile_commands.json',
exclude_paths=[exclude_path_1]) exclude_paths=[exclude_path_1])
ret, stdout, stderr = cppcheck(['--project=proj2/test.cppcheck']) ret, stdout, stderr = cppcheck(['--project=proj2/test.cppcheck'])
file1 = 'proj2/a/a.c' file1 = os.path.join('proj2', 'a', 'a.c')
file2 = 'proj2/b/b.c' # Excluded by test.cppcheck file2 = os.path.join('proj2', 'b', 'b.c') # Excluded by test.cppcheck
assert ret == 0, stdout assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 0 assert stdout.find('Checking %s ...' % file1) >= 0
assert stdout.find('Checking %s ...' % file2) < 0 assert stdout.find('Checking %s ...' % file2) < 0

View File

@ -43,22 +43,12 @@ def create_gui_project_file(project_file, root_path=None, import_project=None, p
# Run Cppcheck with args # Run Cppcheck with args
def cppcheck(args): def cppcheck(args):
exe = None exe = None
if os.path.isfile('../../cppcheck.exe'): for ext in ('', '.exe'):
exe = '../../cppcheck.exe' for base in ('../../', '../../../'):
elif os.path.isfile('../../../cppcheck.exe'): for path in ('', 'bin/', 'bin/debug/'):
exe = '../../../cppcheck.exe' if (exe is None) and os.path.isfile(base + path + 'cppcheck' + ext):
elif os.path.isfile('../../bin/cppcheck.exe'): exe = base + path + 'cppcheck' + ext
exe = '../../bin/cppcheck.exe' assert exe is not None
elif os.path.isfile('../../../bin/cppcheck.exe'):
exe = '../../../bin/cppcheck.exe'
elif os.path.isfile('../../bin/cppcheck'):
exe = '../../bin/cppcheck'
elif os.path.isfile('../../../bin/cppcheck'):
exe = '../../../bin/cppcheck'
elif os.path.isfile('../../cppcheck'):
exe = '../../cppcheck'
else:
exe = '../../../cppcheck'
logging.info(exe + ' ' + ' '.join(args)) logging.info(exe + ' ' + ' '.join(args))
p = subprocess.Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)