tests should not fail by failing to clean up. Make clean up more reliable on windows

This commit is contained in:
arvidn 2017-07-03 21:00:33 -04:00 committed by Arvid Norberg
parent 10bfe18ebe
commit 6425cfbc4f
1 changed files with 10 additions and 1 deletions

View File

@ -254,7 +254,16 @@ struct unit_directory_guard
return;
}
remove_all(dir, ec);
if (ec) TEST_ERROR("Failed to remove unit test directory: " + ec.message());
#ifdef TORRENT_WINDOWS
if (ec.value() == ERROR_SHARING_VIOLATION)
{
// on windows, files are removed in the background, and we may need
// to wait a little bit
std::this_thread::sleep_for(milliseconds(400));
remove_all(dir, ec);
}
#endif
if (ec) std::cerr << "Failed to remove unit test directory: " << ec.message() << "\n";
}
};