Spinning Topp Logo BlackTopp Studios
inc
Classes | Functions | Variables
mezztest.cpp File Reference

This file is the entry point for the unit test framework. More...

#include "autodetect.h"
#include "datatypes.h"
#include "mezztest.h"
#include <cstdlib>
#include <fstream>
#include <vector>
#include <stdexcept>
+ Include dependency graph for mezztest.cpp:

Go to the source code of this file.

Classes

class  AllUnitTestGroups
 This aggregates the results of all the other test groups. More...
 

Functions

void ClearTempFile ()
 Empty the file specified by TempFile. More...
 
void DeleteTempFile ()
 Attempts to delete TempFile. Silently fails if not possible.
 
ProcessDepth GetCurrentProcessDepth ()
 Indicates what this test might attempt to do, based on what it thinks the process depth is. More...
 
Mezzanine::String GetExecutableName ()
 Get the command/executable name used to invoke this at the command prompt. More...
 
int GetMainArgumentCount ()
 Get the argument count as it was passed into Main. More...
 
char ** GetMainArgumentVector ()
 Get the argument vector as it was passed into Main. More...
 
UnitTestGroup GetResultsFromTempFile ()
 This will open then parse the contents of the file specified by TempFile and interpret any test results located. More...
 
Mezzanine::String GetSubSubProcessArgument ()
 If a test needs to pass a string to a subsubprocess it will get stored here. More...
 
void HandleSingleArgument (Mezzanine::String Arg)
 Handles one argument at a time for main. More...
 
int main (int argc, char **argv)
 This is the entry point for the unit test executable. More...
 
void WriteTempFile (const UnitTestGroup &TestsToWrite)
 Write the passed UnitTestGroup to an XML temp file. More...
 

Variables

int ArgC
 ArgC as it was passed into Main. More...
 
char ** ArgV
 ArgC as it was passed into Main. More...
 
Mezzanine::String CommandName
 This will store the name of the command that launched this executable at run time. More...
 
ProcessDepth Depth
 The current process depth as interpretted by Main. More...
 
Mezzanine::String SubSubProcessArgument
 A string intended for use by any subsubprocess test. More...
 

Detailed Description

This file is the entry point for the unit test framework.

If you need to change the nature of the executable this is the file to change. This is where the simple (but robust) sub process mechanism is implemented. Very little of the rest of the code in the unit test frame work makes calls to this file, and everything that does does so through the UnitTestGroup class via polymorphism.

Definition in file mezztest.cpp.

Function Documentation

void ClearTempFile ( )

Empty the file specified by TempFile.

Warning
This doesn't ask for permission and can't easily be cancelled or recovered from. This will open, then erase the contents of the file.
Exceptions
Thiscan throw any exception that the C++ filestream classes can throw.

Definition at line 137 of file mezztest.cpp.

ProcessDepth GetCurrentProcessDepth ( )

Indicates what this test might attempt to do, based on what it thinks the process depth is.

Returns
a ProcessDepth enum member

Definition at line 83 of file mezztest.cpp.

Mezzanine::String GetExecutableName ( )

Get the command/executable name used to invoke this at the command prompt.

Returns
This is returned as a String.

Definition at line 77 of file mezztest.cpp.

int GetMainArgumentCount ( )

Get the argument count as it was passed into Main.

Returns
This is returned as an int

Definition at line 63 of file mezztest.cpp.

char** GetMainArgumentVector ( )

Get the argument vector as it was passed into Main.

Returns
This is returned as pointer to a null terminated array of pointers to null terminated characters.

Definition at line 71 of file mezztest.cpp.

UnitTestGroup GetResultsFromTempFile ( )

This will open then parse the contents of the file specified by TempFile and interpret any test results located.

Exceptions
Thiscan throw any exception that the C++ filestream classes can throw.
Returns
This "reads" the temp file and interprets it. It tries to extract the name of the test as the whole of a line minus the last word. The last word is then converted into a TestResult using StringToTestResult . Any Whitespace between between the end of the last word and the end of the test name is dropped. All lines are interpretted this way and returned as a single UnitTestGroup.

Definition at line 109 of file mezztest.cpp.

Mezzanine::String GetSubSubProcessArgument ( )

If a test needs to pass a string to a subsubprocess it will get stored here.

Returns
A string that a test group intends on passing into a subsubprocess test

Definition at line 89 of file mezztest.cpp.

void HandleSingleArgument ( Mezzanine::String  Arg)

Handles one argument at a time for main.

This should be the only place that configures global state in the test suite everywhere else should access global state through the accessors in mezztest.h

Parameters
ArgThe argument

Definition at line 312 of file mezztest.cpp.

int main ( int  argc,
char **  argv 
)

This is the entry point for the unit test executable.

This will contruct an AllUnitTestGroups with the listing of unit tests available from autodetect.h. It will then interpret any command line arguments and direct the created AllUnitTestGroups about which tests to run and how to run them. In addition to sending the results to the standard output a copy of the test results will be written to TestResults.txt, if not configure not to.

If no arguments are passed this will add all the tests to the AllUnitTestGroups and execute all tests that are not interactive. Print out a default report of them.

Returns
This will return EXIT_SUCCESS if the tests ran, even if some or all failed, even if a child process segfaulted, but will return other statuses only if the main process fails. If the main process cannot create child processes it will return EXIT_FAILURE.
Parameters
argcIs interpretted as the amount of passed arguments
argvIs interpretted as the arguments passed in from the launching shell.

Definition at line 332 of file mezztest.cpp.

void WriteTempFile ( const UnitTestGroup &  TestsToWrite)

Write the passed UnitTestGroup to an XML temp file.

Parameters
TestsToWriteTeh group of tests to write.

Definition at line 95 of file mezztest.cpp.

Variable Documentation

int ArgC

ArgC as it was passed into Main.

This cannot be set statically, it must wait for main(int, char**) to be initialized

Definition at line 62 of file mezztest.cpp.

char** ArgV

ArgC as it was passed into Main.

This cannot be set statically, it must wait for main(int, char**) to be initialized

Definition at line 70 of file mezztest.cpp.

Mezzanine::String CommandName

This will store the name of the command that launched this executable at run time.

Definition at line 76 of file mezztest.cpp.

ProcessDepth Depth

The current process depth as interpretted by Main.

Definition at line 82 of file mezztest.cpp.

Mezzanine::String SubSubProcessArgument

A string intended for use by any subsubprocess test.

Definition at line 88 of file mezztest.cpp.