Commit 955ccd42 authored by T.J. Corona's avatar T.J. Corona Committed by Kitware Robot
Browse files

Merge topic 'clean-up-after-testing'

c9bfc36d

 Testing: clean up tmp files after creation, and use unique file names.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: David Thompson's avatarDavid Thompson <david.thompson@kitware.com>
Merge-request: !543
parents c70d60fe c9bfc36d
......@@ -23,7 +23,7 @@ set(basicAttributeXMLWriterTest_ARGS
set(childrenItemsTest_ARGS "dummy.sbi")
foreach(tst ${attributeTests})
add_executable(${tst} ${tst}.cxx)
target_link_libraries(${tst} smtkCore)
target_link_libraries(${tst} smtkCore ${Boost_LIBRARIES})
add_test(NAME ${tst} COMMAND ${tst} ${${tst}_ARGS})
endforeach()
......@@ -44,7 +44,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/cmb-testing-data.marker)
)
foreach(tst ${attributeDataTests})
add_executable(${tst} ${tst}.cxx)
target_link_libraries(${tst} smtkCore)
target_link_libraries(${tst} smtkCore ${Boost_LIBRARIES})
add_test(NAME ${tst} COMMAND ${tst} ${${tst}_ARGS})
endforeach()
endif()
......
......@@ -31,6 +31,22 @@
#include <iostream>
//force to use filesystem version 3
#define BOOST_FILESYSTEM_VERSION 3
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
void cleanup( const std::string& file_path )
{
//first verify the file exists
::boost::filesystem::path path( file_path );
if( ::boost::filesystem::is_regular_file( path ) )
{
//remove the file_path if it exists.
::boost::filesystem::remove( path );
}
}
int main(int argc, char *argv[])
{
int status = 0;
......@@ -206,6 +222,10 @@ int main(int argc, char *argv[])
}
std::cout << "System destroyed\n";
cleanup(argv[1]);
cleanup(argv[2]);
}
return status;
}
......@@ -32,6 +32,22 @@
#include <iostream>
//force to use filesystem version 3
#define BOOST_FILESYSTEM_VERSION 3
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
void cleanup( const std::string& file_path )
{
//first verify the file exists
::boost::filesystem::path path( file_path );
if( ::boost::filesystem::is_regular_file( path ) )
{
//remove the file_path if it exists.
::boost::filesystem::remove( path );
}
}
const char *d2items[] = {
"IntItem1", "IntItem2", "DoubleItem1", "DoubleItem2", "StringItem1", "StringItem2", "StringItem3",
"FileItem1", "FileItem2", "FileItem3","DirectoryItem1", "DirectoryItem2", "DirectoryItem3"
......@@ -926,6 +942,7 @@ int main(int argc, char *argv[])
if (status == 0)
{
std::cout << "All Test PASSED!\n";
cleanup(outputFilename);
}
else
{
......
......@@ -110,6 +110,7 @@ class TestDiscreteCreateAndSaveEdges(smtk.testing.TestCase):
validator(mod)
print ' Success'
os.remove(outfilename)
def testCreateAndSaveEdges(self):
"Read each file named in setUp and validate the reader worked."
......
......@@ -10,6 +10,8 @@
#include "smtk/bridge/mesh/Session.h"
#include "smtk/common/UUID.h"
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/FileItem.h"
#include "smtk/attribute/IntItem.h"
......@@ -35,7 +37,6 @@ namespace
std::string dataRoot = SMTK_DATA_DIR;
std::string writeRoot = SMTK_SCRATCH_DIR;
#if 0
void cleanup( const std::string& file_path )
{
//first verify the file exists
......@@ -46,7 +47,6 @@ void cleanup( const std::string& file_path )
::boost::filesystem::remove( path );
}
}
#endif // 0
}
......@@ -114,7 +114,7 @@ int UnitTestMeshSessionReadWrite(int argc, char* argv[])
}
std::string writeFilePath(writeRoot);
writeFilePath += "/output.exo";
writeFilePath += "/" + smtk::common::UUID::random().toString() + ".exo";
writeOp->specification()->findFile("filename")->setValue(writeFilePath);
writeOp->specification()->associateEntity(model);
......@@ -127,7 +127,7 @@ int UnitTestMeshSessionReadWrite(int argc, char* argv[])
return 1;
}
// cleanup(writeFilePath);
cleanup(writeFilePath);
}
return 0;
......
......@@ -26,7 +26,6 @@ namespace
//SMTK_DATA_DIR is a define setup by cmake
std::string data_root = SMTK_DATA_DIR;
std::string write_root = SMTK_SCRATCH_DIR;
void create_simple_mesh_model( smtk::model::ManagerPtr mgr )
{
......
......@@ -8,6 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/UUID.h"
#include "smtk/io/ExportMesh.h"
#include "smtk/io/ImportMesh.h"
#include "smtk/mesh/Collection.h"
......@@ -42,7 +43,7 @@ void cleanup( const std::string& file_path )
void verify_write_empty_collection()
{
std::string write_path(write_root);
write_path += "/output.2dm";
write_path += "/" + smtk::common::UUID::random().toString() + ".2dm";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::mesh::CollectionPtr c = manager->makeCollection();
......@@ -58,7 +59,7 @@ void verify_write_empty_collection()
void verify_write_null_collection()
{
std::string write_path(write_root);
write_path += "/output.2dm";
write_path += "/" + smtk::common::UUID::random().toString() + ".2dm";
//use a null collection ptr
smtk::mesh::CollectionPtr c;
......@@ -77,7 +78,7 @@ void verify_write_valid_collection()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/twoassm_output.2dm";
write_path += "/" + smtk::common::UUID::random().toString() + ".2dm";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::mesh::CollectionPtr c = smtk::io::importMesh(file_path, manager);
......
......@@ -8,6 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/UUID.h"
#include "smtk/io/ExportMesh.h"
#include "smtk/io/ImportMesh.h"
#include "smtk/io/ReadMesh.h"
......@@ -43,7 +44,7 @@ void cleanup( const std::string& file_path )
void verify_write_empty_collection()
{
std::string write_path(write_root);
write_path += "/output.3dm";
write_path += "/" + smtk::common::UUID::random().toString() + ".3dm";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::mesh::CollectionPtr c = manager->makeCollection();
......@@ -59,7 +60,7 @@ void verify_write_empty_collection()
void verify_write_null_collection()
{
std::string write_path(write_root);
write_path += "/output.3dm";
write_path += "/" + smtk::common::UUID::random().toString() + ".3dm";
//use a null collection ptr
smtk::mesh::CollectionPtr c;
......@@ -78,7 +79,7 @@ void verify_write_valid_collection()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/twoassm_output.3dm";
write_path += "/" + smtk::common::UUID::random().toString() + ".3dm";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::mesh::CollectionPtr c = smtk::io::readMesh(file_path, manager);
......
......@@ -8,6 +8,8 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/UUID.h"
#include "smtk/io/LoadJSON.h"
#include "smtk/io/ModelToMesh.h"
#include "smtk/io/WriteMesh.h"
......@@ -207,7 +209,7 @@ void verify_write_valid_collection_hdf5_after_merge()
// write out the collection after mergeCoincidentContactPoints()
std::string write_path(write_root);
write_path += "/test2D_json_output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
//write out the mesh.
bool result = smtk::io::writeMesh(write_path, c);
......
......@@ -8,6 +8,8 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/UUID.h"
#include "smtk/io/SaveJSON.h"
#include "smtk/io/LoadJSON.h"
#include "smtk/io/ImportMesh.h"
......@@ -68,7 +70,7 @@ void create_simple_model( smtk::model::ManagerPtr mgr )
void verify_writing_and_loading_collection()
{
std::string write_path(write_root);
write_path += "/output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::model::ManagerPtr modelManager = smtk::model::Manager::create();
smtk::mesh::ManagerPtr meshManager = modelManager->meshes();
......@@ -126,8 +128,8 @@ void verify_writing_and_loading_multiple_collections()
std::string write_path(write_root);
std::string write_path2(write_root);
write_path += "/output1.h5m";
write_path2 += "/output2.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
write_path2 += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::model::ManagerPtr modelManager = smtk::model::Manager::create();
smtk::mesh::ManagerPtr meshManager = modelManager->meshes();
......@@ -170,7 +172,7 @@ void verify_writing_and_loading_multiple_collections()
void verify_writing_and_loading_collections_without_file_path()
{
std::string write_path(write_root);
write_path += "/output1.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::model::ManagerPtr modelManager = smtk::model::Manager::create();
smtk::mesh::ManagerPtr meshManager = modelManager->meshes();
......@@ -251,7 +253,7 @@ void verify_writing_of_single_collection_to_disk()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ImportMesh import;
......@@ -274,6 +276,8 @@ void verify_writing_of_single_collection_to_disk()
const bool exportGood = smtk::io::SaveJSON::forSingleCollection(top, c) != 0;
test(exportGood == 1, "Expected the Export of forSingleCollection to pass");
cleanup( write_path );
}
void verify_writing_of_single_collection_to_json()
......@@ -331,7 +335,7 @@ void verify_reading_of_single_collection_from_json()
// By default, the writeLocation is set to readLocation, and we don't want
// this test to write to the input file, so set writeLocation to scratch space
write_path += "/twoassm_output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
c->writeLocation(write_path);
const bool exportGood = smtk::io::SaveJSON::forSingleCollection(top, c) != 0;
......@@ -376,7 +380,7 @@ void verify_reading_of_single_collection_from_json()
void verify_loading_existing_collection_fails()
{
std::string write_path(write_root);
write_path += "/output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::model::ManagerPtr modelManager = smtk::model::Manager::create();
smtk::mesh::ManagerPtr meshManager = modelManager->meshes();
......
......@@ -10,7 +10,6 @@
#include "smtk/io/LoadJSON.h"
#include "smtk/io/ModelToMesh.h"
#include "smtk/io/WriteMesh.h"
#include "smtk/mesh/Collection.h"
#include "smtk/mesh/Manager.h"
......@@ -37,7 +36,6 @@ namespace
//SMTK_DATA_DIR is a define setup by cmake
std::string data_root = SMTK_DATA_DIR;
std::string write_root = SMTK_SCRATCH_DIR;
void create_simple_2d_model( smtk::model::ManagerPtr mgr )
{
......
......@@ -8,6 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/UUID.h"
#include "smtk/io/ReadMesh.h"
#include "smtk/io/WriteMesh.h"
#include "smtk/mesh/Collection.h"
......@@ -45,7 +46,7 @@ void verify_write_empty_collection()
file_path += "/mesh/output.h5m";
std::string write_path(write_root);
write_path += "/output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::mesh::CollectionPtr c = manager->makeCollection();
......@@ -62,7 +63,7 @@ void verify_write_empty_collection()
void verify_write_null_collection()
{
std::string write_path(write_root);
write_path += "/output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
//use a null collection ptr
smtk::mesh::CollectionPtr c;
......@@ -82,7 +83,7 @@ void verify_write_valid_collection_hdf5()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/twoassm_output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......@@ -120,7 +121,7 @@ void verify_write_valid_collection_exodus()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/twoassm_output.exo";
write_path += "/" + smtk::common::UUID::random().toString() + ".exo";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......@@ -157,7 +158,7 @@ void verify_write_valid_collection_using_write_path()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/twoassm_output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......@@ -199,7 +200,7 @@ void verify_write_valid_collection_using_functions()
file_path += "/mesh/3d/twoassm_out.h5m";
std::string write_path(write_root);
write_path += "/twoassm_output.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::mesh::CollectionPtr c = smtk::io::readMesh(file_path, manager);
......@@ -239,7 +240,7 @@ void verify_write_onlyDomain()
file_path += "/mesh/3d/64bricks_12ktet.h5m";
std::string write_path(write_root);
write_path += "/64bricks_12ktet.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......@@ -280,7 +281,7 @@ void verify_write_onlyNeumann()
file_path += "/mesh/3d/64bricks_12ktet.h5m";
std::string write_path(write_root);
write_path += "/64bricks_12ktet.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......@@ -324,7 +325,7 @@ void verify_write_onlyDirichlet()
file_path += "/mesh/3d/64bricks_12ktet.h5m";
std::string write_path(write_root);
write_path += "/64bricks_12ktet.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......@@ -366,7 +367,7 @@ void verify_write_clears_modified_flag()
file_path += "/mesh/3d/64bricks_12ktet.h5m";
std::string write_path(write_root);
write_path += "/64bricks_12ktet.h5m";
write_path += "/" + smtk::common::UUID::random().toString() + ".h5m";
smtk::mesh::ManagerPtr manager = smtk::mesh::Manager::create();
smtk::io::ReadMesh read;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment