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))
return;
const std::vector<std::string> basePaths{Path::getCurrentPath()};
const std::vector<std::string> basePaths{Path::fromNativeSeparators(Path::getCurrentPath())};
for (auto &fs: fileSettings) {
fs.filename = Path::getRelativePath(fs.filename, basePaths);
for (auto &includePath: fs.includePaths)

View File

@ -20,7 +20,7 @@ def realpath(s):
def create_compile_commands():
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'}]
f = open('proj2/' + COMPILE_COMMANDS_JSON, 'wt')
with open('proj2/' + COMPILE_COMMANDS_JSON, 'wt') as f:
f.write(json.dumps(j))
# Run Cppcheck from project path
@ -44,8 +44,8 @@ def test_file_filter():
def test_local_path():
create_compile_commands()
ret, stdout, stderr = cppcheck_local(['--project=compile_commands.json'])
file1 = 'a/a.c'
file2 = 'b/b.c'
file1 = os.path.join('a', 'a.c')
file2 = os.path.join('b', 'b.c')
assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 0
assert stdout.find('Checking %s ...' % file2) >= 0
@ -65,8 +65,8 @@ def test_local_path_maxconfigs():
def test_relative_path():
create_compile_commands()
ret, stdout, stderr = cppcheck(['--project=proj2/' + COMPILE_COMMANDS_JSON])
file1 = 'proj2/a/a.c'
file2 = 'proj2/b/b.c'
file1 = os.path.join('proj2', 'a', 'a.c')
file2 = os.path.join('proj2', 'b', 'b.c')
assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 0
assert stdout.find('Checking %s ...' % file2) >= 0
@ -83,8 +83,8 @@ def test_absolute_path():
def test_gui_project_loads_compile_commands_1():
create_compile_commands()
ret, stdout, stderr = cppcheck(['--project=proj2/proj2.cppcheck'])
file1 = 'proj2/a/a.c'
file2 = 'proj2/b/b.c'
file1 = os.path.join('proj2', 'a', 'a.c')
file2 = os.path.join('proj2', 'b', 'b.c')
assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 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',
exclude_paths=[exclude_path_1])
ret, stdout, stderr = cppcheck(['--project=proj2/test.cppcheck'])
file1 = 'proj2/a/a.c'
file2 = 'proj2/b/b.c' # Excluded by test.cppcheck
file1 = os.path.join('proj2', 'a', 'a.c')
file2 = os.path.join('proj2', 'b', 'b.c') # Excluded by test.cppcheck
assert ret == 0, stdout
assert stdout.find('Checking %s ...' % file1) >= 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
def cppcheck(args):
exe = None
if os.path.isfile('../../cppcheck.exe'):
exe = '../../cppcheck.exe'
elif os.path.isfile('../../../cppcheck.exe'):
exe = '../../../cppcheck.exe'
elif os.path.isfile('../../bin/cppcheck.exe'):
exe = '../../bin/cppcheck.exe'
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'
for ext in ('', '.exe'):
for base in ('../../', '../../../'):
for path in ('', 'bin/', 'bin/debug/'):
if (exe is None) and os.path.isfile(base + path + 'cppcheck' + ext):
exe = base + path + 'cppcheck' + ext
assert exe is not None
logging.info(exe + ' ' + ' '.join(args))
p = subprocess.Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)