mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12598 from a3d4/case-insensitive-root-in-normalizeclipathforvfs
Treat root path in normalizeCLIPathForVFS as case insensitive on Windows
This commit is contained in:
commit
28bc5db576
@ -269,7 +269,8 @@ boost::filesystem::path FileReader::normalizeCLIPathForVFS(
|
|||||||
if (!isUNCPath(normalizedPath))
|
if (!isUNCPath(normalizedPath))
|
||||||
{
|
{
|
||||||
boost::filesystem::path workingDirRootPath = canonicalWorkDir.root_path();
|
boost::filesystem::path workingDirRootPath = canonicalWorkDir.root_path();
|
||||||
if (normalizedRootPath == workingDirRootPath)
|
// Ignore drive letter case on Windows (C:\ <=> c:\).
|
||||||
|
if (boost::filesystem::equivalent(normalizedRootPath, workingDirRootPath))
|
||||||
normalizedRootPath = "/";
|
normalizedRootPath = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <test/TemporaryDirectory.h>
|
#include <test/TemporaryDirectory.h>
|
||||||
#include <test/libsolidity/util/SoltestErrors.h>
|
#include <test/libsolidity/util/SoltestErrors.h>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -192,8 +193,8 @@ BOOST_AUTO_TEST_CASE(normalizeCLIPathForVFS_root_name_only)
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
boost::filesystem::path driveLetter = boost::filesystem::current_path().root_name();
|
boost::filesystem::path driveLetter = boost::filesystem::current_path().root_name();
|
||||||
solAssert(!driveLetter.empty(), "");
|
soltestAssert(!driveLetter.empty(), "");
|
||||||
solAssert(driveLetter.is_relative(), "");
|
soltestAssert(driveLetter.is_relative(), "");
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(FileReader::normalizeCLIPathForVFS(driveLetter, resolveSymlinks), expectedWorkDir);
|
BOOST_CHECK_EQUAL(FileReader::normalizeCLIPathForVFS(driveLetter, resolveSymlinks), expectedWorkDir);
|
||||||
#endif
|
#endif
|
||||||
@ -212,13 +213,32 @@ BOOST_AUTO_TEST_CASE(normalizeCLIPathForVFS_stripping_root_name)
|
|||||||
|
|
||||||
for (SymlinkResolution resolveSymlinks: {SymlinkResolution::Enabled, SymlinkResolution::Disabled})
|
for (SymlinkResolution resolveSymlinks: {SymlinkResolution::Enabled, SymlinkResolution::Disabled})
|
||||||
{
|
{
|
||||||
|
boost::filesystem::path workDir = boost::filesystem::current_path();
|
||||||
|
|
||||||
boost::filesystem::path normalizedPath = FileReader::normalizeCLIPathForVFS(
|
boost::filesystem::path normalizedPath = FileReader::normalizeCLIPathForVFS(
|
||||||
boost::filesystem::current_path(),
|
workDir,
|
||||||
resolveSymlinks
|
resolveSymlinks
|
||||||
);
|
);
|
||||||
BOOST_CHECK_EQUAL(normalizedPath, "/" / boost::filesystem::current_path().relative_path());
|
BOOST_CHECK_EQUAL(normalizedPath, "/" / workDir.relative_path());
|
||||||
BOOST_TEST(normalizedPath.root_name().empty());
|
BOOST_TEST(normalizedPath.root_name().empty());
|
||||||
BOOST_CHECK_EQUAL(normalizedPath.root_directory(), "/");
|
BOOST_CHECK_EQUAL(normalizedPath.root_directory(), "/");
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
string root = workDir.root_path().string();
|
||||||
|
soltestAssert(root.length() == 3 && root[1] == ':' && root[2] == '\\', "");
|
||||||
|
|
||||||
|
for (auto convert: {boost::to_lower_copy<string>, boost::to_upper_copy<string>})
|
||||||
|
{
|
||||||
|
boost::filesystem::path workDirWin = convert(root, locale()) / workDir.relative_path();
|
||||||
|
normalizedPath = FileReader::normalizeCLIPathForVFS(
|
||||||
|
workDirWin,
|
||||||
|
resolveSymlinks
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(normalizedPath, "/" / workDir.relative_path());
|
||||||
|
BOOST_TEST(normalizedPath.root_name().empty());
|
||||||
|
BOOST_CHECK_EQUAL(normalizedPath.root_directory(), "/");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user