Tests: Do not remove filename from boost filesystem path for corner

cases.

Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
Bhargava Shastry
2021-02-22 10:32:41 +01:00
co-authored by Kamil Śliwak
parent 6fd5ea01d1
commit 1ddfc7463a
4 changed files with 14 additions and 3 deletions
+5 -1
View File
@@ -137,7 +137,11 @@ string solidity::util::absolutePath(string const& _path, string const& _referenc
if (p.begin() == p.end() || (*p.begin() != "." && *p.begin() != ".."))
return _path;
boost::filesystem::path result(_reference);
result.remove_filename();
// If filename is "/", then remove_filename() throws.
// See: https://github.com/boostorg/filesystem/issues/176
if (result.filename() != boost::filesystem::path("/"))
result.remove_filename();
for (boost::filesystem::path::iterator it = p.begin(); it != p.end(); ++it)
if (*it == "..")
result = result.parent_path();