Skip to content

Commit fc8bf23

Browse files
committed
test/cli/project_test.py: adjusted results for execution on Windows
1 parent f195502 commit fc8bf23

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎lib/importproject.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,11 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const
455455
if (pos1 == std::string::npos)
456456
continue;
457457
std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
458+
vcxproj = Path::toNativeSeparators(std::move(vcxproj));
458459
if (!Path::isAbsolute(vcxproj))
459460
vcxproj = path + vcxproj;
460-
if (!importVcxproj(Path::fromNativeSeparators(vcxproj), variables, emptyString, fileFilters)) {
461+
vcxproj = Path::fromNativeSeparators(std::move(vcxproj));
462+
if (!importVcxproj(vcxproj, variables, emptyString, fileFilters)) {
461463
printError("failed to load '" + vcxproj + "' from Visual Studio solution");
462464
return false;
463465
}

‎test/cli/project_test.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44
import os
55
import json
6+
import sys
67
from testutils import cppcheck
78

89

@@ -49,6 +50,8 @@ def test_json_entry_file_not_found(tmpdir):
4950
]
5051

5152
expected = "'{}' from compilation database does not exist".format(os.path.join(tmpdir, "bug1.cpp"))
53+
if sys.platform == "win32":
54+
expected = expected.replace('\\', '/')
5255

5356
_test_project_error(tmpdir, "json", json.dumps(compilation_db), expected)
5457

@@ -117,7 +120,9 @@ def test_sln_project_file_not_found(tmpdir):
117120
"EndProject\r\n"
118121

119122
expected = "Visual Studio project file is not a valid XML - XML_ERROR_FILE_NOT_FOUND\n" \
120-
"cppcheck: error: failed to load '{}' from Visual Studio solution".format(os.path.join(tmpdir, "cli\\cli.vcxproj"))
123+
"cppcheck: error: failed to load '{}' from Visual Studio solution".format(os.path.join(tmpdir, "cli/cli.vcxproj"))
124+
if sys.platform == "win32":
125+
expected = expected.replace('\\', '/')
121126

122127
_test_project_error(tmpdir, "sln", content, expected)
123128

0 commit comments

Comments
 (0)