Skip to content
Snippets Groups Projects
Commit 935783b1 authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #2269: More robust file handling in test.

parent 5763dc92
No related merge requests found
......@@ -363,16 +363,13 @@ public:
std::string filename_root = "LoadNexusProcessed_ExecEvent_";
// Call a function that writes out the file
EventWorkspace_sptr origWS = SaveNexusProcessedTest::do_testExec_EventWorkspaces(filename_root, type, false, false);
std::string outputFile;
EventWorkspace_sptr origWS = SaveNexusProcessedTest::do_testExec_EventWorkspaces(filename_root, type, outputFile, false, false);
LoadNexusProcessed alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize());
TS_ASSERT( alg.isInitialized() );
std::ostringstream filename;
filename << filename_root << static_cast<int>(type) << ".nxs";
testFile= filename.str();
alg.setPropertyValue("Filename", testFile);
std::string outputFile = alg.getPropertyValue("Filename");
alg.setPropertyValue("Filename", outputFile);
alg.setPropertyValue("OutputWorkspace", output_ws);
TS_ASSERT_THROWS_NOTHING(alg.execute());
......@@ -422,7 +419,7 @@ public:
//TS_ASSERT( equals(origWS, ws, 1e-4) );
//Clear old file
//if( Poco::File(outputFile).exists() ) Poco::File(outputFile).remove();
if( Poco::File(outputFile).exists() ) Poco::File(outputFile).remove();
}
......
......@@ -307,7 +307,7 @@ public:
static EventWorkspace_sptr do_testExec_EventWorkspaces(std::string filename_root, EventType type,
bool makeDifferentTypes=false, bool clearfiles=false)
std::string & outputFile, bool makeDifferentTypes, bool clearfiles)
{
std::vector< std::vector<int> > groups(5);
groups[0].push_back(10);
......@@ -345,7 +345,7 @@ public:
// specify name of file to save workspace to
std::ostringstream mess;
mess << filename_root << static_cast<int>(type) << ".nxs";
std::string outputFile = mess.str();
outputFile = mess.str();
std::string dataName = "spectra";
std::string title = "A simple workspace saved in Processed Nexus format";
......@@ -368,22 +368,26 @@ public:
void testExec_EventWorkspace_TofEvent()
{
do_testExec_EventWorkspaces("SaveNexusProcessed_", TOF, false, clearfiles);
std::string outputFile;
do_testExec_EventWorkspaces("SaveNexusProcessed_", TOF, outputFile, false, clearfiles);
}
void testExec_EventWorkspace_WeightedEvent()
{
do_testExec_EventWorkspaces("SaveNexusProcessed_", WEIGHTED, false, clearfiles);
std::string outputFile;
do_testExec_EventWorkspaces("SaveNexusProcessed_", WEIGHTED, outputFile, false, clearfiles);
}
void testExec_EventWorkspace_WeightedEventNoTime()
{
do_testExec_EventWorkspaces("SaveNexusProcessed_", WEIGHTED_NOTIME, false, clearfiles);
std::string outputFile;
do_testExec_EventWorkspaces("SaveNexusProcessed_", WEIGHTED_NOTIME, outputFile, false, clearfiles);
}
void testExec_EventWorkspace_DifferentTypes()
{
do_testExec_EventWorkspaces("SaveNexusProcessed_DifferentTypes_", WEIGHTED_NOTIME, true, clearfiles);
std::string outputFile;
do_testExec_EventWorkspaces("SaveNexusProcessed_DifferentTypes_", WEIGHTED_NOTIME, outputFile, true, clearfiles);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment