Skip to content

Commit

Permalink
test/cli/project_test.py: adjusted results for execution on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Jan 12, 2024
1 parent f195502 commit fc8bf23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,11 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const
if (pos1 == std::string::npos)
continue;
std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
vcxproj = Path::toNativeSeparators(std::move(vcxproj));
if (!Path::isAbsolute(vcxproj))
vcxproj = path + vcxproj;
if (!importVcxproj(Path::fromNativeSeparators(vcxproj), variables, emptyString, fileFilters)) {
vcxproj = Path::fromNativeSeparators(std::move(vcxproj));
if (!importVcxproj(vcxproj, variables, emptyString, fileFilters)) {
printError("failed to load '" + vcxproj + "' from Visual Studio solution");
return false;
}
Expand Down
7 changes: 6 additions & 1 deletion test/cli/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
import os
import json
import sys
from testutils import cppcheck


Expand Down Expand Up @@ -49,6 +50,8 @@ def test_json_entry_file_not_found(tmpdir):
]

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

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

Expand Down Expand Up @@ -117,7 +120,9 @@ def test_sln_project_file_not_found(tmpdir):
"EndProject\r\n"

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

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

Expand Down

0 comments on commit fc8bf23

Please sign in to comment.