Save and restore current_path in TestingSetup constructor/destructor
This commit is contained in:
parent
ab24201507
commit
0ade29546f
|
@ -93,6 +93,10 @@ TestingSetup::TestingSetup()
|
|||
bitdb.MakeMock();
|
||||
RegisterWalletRPCCommands(tableRPC);
|
||||
#endif
|
||||
|
||||
// Save current path, in case a test changes it
|
||||
orig_current_path = boost::filesystem::current_path();
|
||||
|
||||
ClearDatadirCache();
|
||||
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
|
||||
boost::filesystem::create_directories(pathTemp);
|
||||
|
@ -131,6 +135,10 @@ TestingSetup::~TestingSetup()
|
|||
bitdb.Flush(true);
|
||||
bitdb.Reset();
|
||||
#endif
|
||||
|
||||
// Restore the previous current path so temporary directory can be deleted
|
||||
boost::filesystem::current_path(orig_current_path);
|
||||
|
||||
boost::filesystem::remove_all(pathTemp);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ struct JoinSplitTestingSetup: public BasicTestingSetup {
|
|||
*/
|
||||
struct TestingSetup: public JoinSplitTestingSetup {
|
||||
CCoinsViewDB *pcoinsdbview;
|
||||
boost::filesystem::path orig_current_path;
|
||||
boost::filesystem::path pathTemp;
|
||||
boost::thread_group threadGroup;
|
||||
|
||||
|
|
Loading…
Reference in New Issue