mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
TemporaryDirectory: Automatically add a dash after the prefix
This commit is contained in:
parent
251de730ed
commit
fb6a25715d
@ -31,7 +31,7 @@ using namespace solidity::test;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
TemporaryDirectory::TemporaryDirectory(std::string const& _prefix):
|
||||
m_path(fs::temp_directory_path() / fs::unique_path(_prefix + "%%%%-%%%%-%%%%-%%%%"))
|
||||
m_path(fs::temp_directory_path() / fs::unique_path(_prefix + "-%%%%-%%%%-%%%%-%%%%"))
|
||||
{
|
||||
// Prefix should just be a file name and not contain anything that would make us step out of /tmp.
|
||||
assert(fs::path(_prefix) == fs::path(_prefix).stem());
|
||||
|
@ -40,7 +40,7 @@ namespace solidity::test
|
||||
class TemporaryDirectory
|
||||
{
|
||||
public:
|
||||
TemporaryDirectory(std::string const& _prefix = "solidity-test-");
|
||||
TemporaryDirectory(std::string const& _prefix = "solidity-test");
|
||||
~TemporaryDirectory();
|
||||
|
||||
boost::filesystem::path const& path() const { return m_path; }
|
||||
|
@ -37,10 +37,10 @@ BOOST_AUTO_TEST_CASE(TemporaryDirectory_should_create_and_delete_a_unique_and_em
|
||||
{
|
||||
fs::path dirPath;
|
||||
{
|
||||
TemporaryDirectory tempDir("temporary-directory-test-");
|
||||
TemporaryDirectory tempDir("temporary-directory-test");
|
||||
dirPath = tempDir.path();
|
||||
|
||||
BOOST_TEST(dirPath.stem().string().find("temporary-directory-test-") == 0);
|
||||
BOOST_TEST(dirPath.stem().string().find("temporary-directory-test") == 0);
|
||||
BOOST_TEST(fs::equivalent(dirPath.parent_path(), fs::temp_directory_path()));
|
||||
BOOST_TEST(fs::is_directory(dirPath));
|
||||
BOOST_TEST(fs::is_empty(dirPath));
|
||||
@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(TemporaryDirectory_should_delete_its_directory_even_if_not_
|
||||
{
|
||||
fs::path dirPath;
|
||||
{
|
||||
TemporaryDirectory tempDir("temporary-directory-test-");
|
||||
TemporaryDirectory tempDir("temporary-directory-test");
|
||||
dirPath = tempDir.path();
|
||||
|
||||
BOOST_TEST(fs::is_directory(dirPath));
|
||||
@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(TemporaryWorkingDirectory_should_change_and_restore_working
|
||||
try
|
||||
{
|
||||
{
|
||||
TemporaryDirectory tempDir("temporary-directory-test-");
|
||||
TemporaryDirectory tempDir("temporary-directory-test");
|
||||
assert(fs::equivalent(fs::current_path(), originalWorkingDirectory));
|
||||
assert(!fs::equivalent(tempDir.path(), originalWorkingDirectory));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user