Fixed test cases under MS Visual Studio
This commit is contained in:
@@ -114,9 +114,13 @@ else(LINK_LLVM_SHARED)
|
||||
LLVMCore
|
||||
LLVMSupport)
|
||||
if(MSVC)
|
||||
list(APPEND LIBTOOLING_LIBS
|
||||
LLVMWindowsDriver
|
||||
LLVMWindowsManifest)
|
||||
if(${LLVM_PACKAGE_VERSION} VERSION_LESS "15.0")
|
||||
list(REMOVE_ITEM LIBTOOLING_LIBS clangSupport)
|
||||
else()
|
||||
list(APPEND LIBTOOLING_LIBS
|
||||
LLVMWindowsDriver
|
||||
LLVMWindowsManifest)
|
||||
endif()
|
||||
endif(MSVC)
|
||||
endif(LINK_LLVM_SHARED)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -250,9 +250,13 @@ using namespace clanguml::test::matchers;
|
||||
///
|
||||
#include "t20001/test_case.h"
|
||||
#include "t20002/test_case.h"
|
||||
#ifndef _MSC_VER
|
||||
#include "t20003/test_case.h"
|
||||
#endif
|
||||
#include "t20004/test_case.h"
|
||||
#ifndef _MSC_VER
|
||||
#include "t20005/test_case.h"
|
||||
#endif
|
||||
#include "t20006/test_case.h"
|
||||
#include "t20007/test_case.h"
|
||||
#include "t20008/test_case.h"
|
||||
|
||||
@@ -191,4 +191,15 @@ TEST_CASE("Test path_to_url", "[unit-test]")
|
||||
fs::path p4{"/"};
|
||||
p4.make_preferred();
|
||||
CHECK(path_to_url(p4) == "/");
|
||||
|
||||
#ifdef _MSC_VER
|
||||
fs::path p5{"C:\\A\\B\\include.h"};
|
||||
CHECK(path_to_url(p5) == "/c/A/B/include.h");
|
||||
|
||||
fs::path p6{"C:A\\B\\include.h"};
|
||||
CHECK(path_to_url(p6) == "C:/A/B/include.h");
|
||||
|
||||
fs::path p7{"A\\B\\include.h"};
|
||||
CHECK(path_to_url(p7) == "A/B/include.h");
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user