Fixed test cases under MS Visual Studio

This commit is contained in:
Bartek Kryza
2023-01-16 23:39:30 +01:00
parent 7a1cbbce9a
commit c49053dcf2
6 changed files with 39 additions and 8 deletions

View File

@@ -330,9 +330,9 @@ void generator::generate_participant(
const auto &relative_to =
std::filesystem::canonical(m_config.relative_to());
auto participant_name = std::filesystem::relative(
auto participant_name = util::path_to_url(std::filesystem::relative(
std::filesystem::path{file_path}, relative_to)
.string();
.string());
ostr << "participant \"" << render_name(participant_name) << "\" as "
<< fmt::format("C_{:022}", file_id);

View File

@@ -2079,9 +2079,9 @@ std::string translation_unit_visitor::make_lambda_name(
const auto location = cls->getLocation();
const auto file_line = source_manager().getSpellingLineNumber(location);
const auto file_column = source_manager().getSpellingColumnNumber(location);
const std::string file_name = std::filesystem::relative(
const std::string file_name = util::path_to_url(std::filesystem::relative(
source_manager().getFilename(location).str(), config().relative_to())
.string();
.string());
if (context().caller_id() != 0 &&
get_participant(context().caller_id()).has_value()) {

View File

@@ -307,8 +307,20 @@ std::string path_to_url(const std::filesystem::path &p)
{
std::vector<std::string> path_tokens;
auto it = p.begin();
if (p.has_root_directory())
if (p.has_root_directory()) {
#ifdef _MSC_VER
// On Windows convert the root path using its drive letter, e.g.:
// C:\A\B\include.h -> /c/A/B/include.h
if(p.root_name().string().size() > 1) {
if(p.is_absolute()) {
path_tokens.push_back(std::string{
std::tolower(p.root_name().string().at(0), std::locale())});
}
it++;
}
#endif
it++;
}
for (; it != p.end(); it++)
path_tokens.push_back(it->string());