Adding Trick Unit Test return code functionality.

This commit is contained in:
Aaron Brogley 2018-03-21 14:01:21 -05:00
parent 29bd27e931
commit 0d7a082b2f
2 changed files with 20 additions and 0 deletions

View File

@ -53,6 +53,9 @@ namespace Trick {
/** Create test xml output.\n*/
bool enabled ; /**< trick_units(--) */
/** Send the unit test exit code up the chain to Executive.\n*/
bool exit_code_enabled ; /**< trick_units(--) */
/** Name of Unit test\n*/
std::string name ;
@ -77,6 +80,12 @@ namespace Trick {
*/
bool enable() ;
/**
@brief Enable/Disable exit code return feature.
@return always 0
*/
int set_exit_code_enabled( bool in_enable ) ;
/**
@brief Output message to the file.
*/

View File

@ -3,6 +3,7 @@
#include <fstream>
#include "trick/UnitTest.hh"
#include "trick/exec_proto.h"
#include "trick/message_proto.h"
#include "trick/message_type.h"
@ -55,6 +56,7 @@ void Trick::TestSuite::delete_test_results() {
Trick::UnitTest::UnitTest() {
the_unit_test_output = this ;
enabled = false ;
exit_code_enabled = false ;
file_name = std::string("test_details.xml") ;
name = std::string("AllTests") ;
}
@ -93,6 +95,11 @@ bool Trick::UnitTest::enable() {
return(true) ;
}
int Trick::UnitTest::set_exit_code_enabled(bool in_enable) {
exit_code_enabled = in_enable ;
return 0 ;
}
int Trick::UnitTest::set_test_name(std::string in_name) {
name = in_name ;
return 0 ;
@ -149,6 +156,10 @@ int Trick::UnitTest::write_output() {
out << " </testsuite>" << std::endl ;
}
out << "</testsuites>" << std::endl ;
if ( exit_code_enabled && num_failures > 0 ) {
exec_terminate_with_return( 1 , __FILE__ , __LINE__ , "Unit Test failure detected." ) ;
}
}
return(0) ;