STORMM Source Documentation
Loading...
Searching...
No Matches
stormm::testing::TestEnvironment Class Reference

Object for parsing as well as storing environment and command-line input relevant to unit testing (Test Driven Development) in STORMM. Environment variables will be sought, but command-line inputs addressing the same information will take precedence. More...

#include <test_environment.h>

Public Member Functions

 ~TestEnvironment ()
 Destructor for the TestEnvironment object must delete the temporary directory if it was created by the constructor. This can only be done after STORMM removes files in the temporary directory known to have been created by the program itself. The actual directory removal is accomplished by a syscall to /bin/rmdir, which will not delete a directory with contents still in it. In this way, the temporary directory can be removed safely without destroying valuable work left by some other user or program.
 
TestVerbosity getVerbosity () const
 Get the verbosity level requested for this test environment.
 
double getTolerance () const
 Get the general tolerance that can be applied in blanket fashion across many tests. This is most useful for regression tests or much higher-level unit tests, as low-level unit test results are often known to very high precision.
 
int getRandomSeed () const
 Get the random seed from the test environment. Separate random seeds can be supplied to any random number generator object at the developer's discretion.
 
std::string getStormmHomePath () const
 Get the STORMM home (test executable and installed library) path.
 
std::string getStormmSourcePath () const
 Get the STORMM source root path.
 
std::string getTemporaryDirectoryPath () const
 Get the temporary directory path that the test environment can use to store files.
 
bool getTemporaryDirectoryAccess () const
 Check whether the temporary directory is accessible to the program.
 
bool doIntensiveTests () const
 Get the directives as to intensive unit test execution.
 
std::vector< std::string > getListOfFilesCreated () const
 Get the list of files that this test program has been given responsibility. It will assume that these files are things it created temporarily and that they should be removed when the TestEnvironment object falls out of scope.
 
SnapshotOperation takeSnapshot () const
 Return whether to record a snapshot of the current data into the named file, or compare the data to an existing file.
 
bool getDisplayTimingsOrder () const
 Return the directive on displaying timings at the end of a test program.
 
void setFileRemoval (const bool remove_files_in)
 Set the file removal flag.
 
void logFileCreated (const std::string &path)
 Catalog that a file has been created by the program. This function will not actually check that the file was created by code recently executed; it just serves as a way to accumulate a list of files that should be regarded as the property of whatever program using the STORMM TestEnvironment object. The program will, however, detect whether an absolute path is in use and make the path absolute if not.
 
 TestEnvironment (int argc, const char *argv[], CommandLineParser *clip, TmpdirStatus tmpdir_required=TmpdirStatus::NOT_REQUIRED, ExceptionResponse policy=ExceptionResponse::WARN)
 The TestEnvironment constructor takes command line arguments but also searches for native environment variables.
 
 TestEnvironment (int argc, const char *argv[], TmpdirStatus tmpdir_required=TmpdirStatus::NOT_REQUIRED, ExceptionResponse policy=ExceptionResponse::WARN)
 
 TestEnvironment (int argc, const char *argv[], ExceptionResponse policy)
 
void logDirectoryCreated (const std::string &path)
 Catalog that a directory has been created by the program. As above, this function will take the developer at their word and accumulates a list of directories that should be regarded as the property of the TestEnvironment object and removed, if possible, when the object is destroyed.
 
void logDirectoryCreated (const std::vector< std::string > &paths)
 

Detailed Description

Object for parsing as well as storing environment and command-line input relevant to unit testing (Test Driven Development) in STORMM. Environment variables will be sought, but command-line inputs addressing the same information will take precedence.

Constructor & Destructor Documentation

◆ TestEnvironment()

stormm::testing::TestEnvironment::TestEnvironment ( int argc,
const char * argv[],
CommandLineParser * clip,
TmpdirStatus tmpdir_required = TmpdirStatus::NOT_REQUIRED,
ExceptionResponse policy = ExceptionResponse::WARN )

The TestEnvironment constructor takes command line arguments but also searches for native environment variables.

Parameters
argcNumber of command line arguments, passed down from the calling program
argvList of command-line arguments
tmpdir_requiredConfirmation that the temporary directory is required for tests. If not required and the temporary directory cannot be created or written to, no warnings will be printed. The directory's status will still be noted.
policyPolicy to take in the event that a command line argument is not recognized

Member Function Documentation

◆ logDirectoryCreated()

void stormm::testing::TestEnvironment::logDirectoryCreated ( const std::string & path)

Catalog that a directory has been created by the program. As above, this function will take the developer at their word and accumulates a list of directories that should be regarded as the property of the TestEnvironment object and removed, if possible, when the object is destroyed.

Overloaded:

  • Take a single path name
  • Take multiple path names (this functionality exists in contrast to logFileCreated, as making a new directory can involve creating a series of new directories)
Parameters
pathName of the directory of interest
pathsList of new directories

◆ logFileCreated()

void stormm::testing::TestEnvironment::logFileCreated ( const std::string & path)

Catalog that a file has been created by the program. This function will not actually check that the file was created by code recently executed; it just serves as a way to accumulate a list of files that should be regarded as the property of whatever program using the STORMM TestEnvironment object. The program will, however, detect whether an absolute path is in use and make the path absolute if not.

Parameters
pathName of the file of interest

◆ setFileRemoval()

void stormm::testing::TestEnvironment::setFileRemoval ( const bool remove_files_in)

Set the file removal flag.

Parameters
remove_files_inThe new flag value

The documentation for this class was generated from the following files: