mirror of
https://github.com/nasa/trick.git
synced 2025-01-31 08:25:41 +00:00
Merge pull request #590 from abrogley/unit-test-return-code
Unit test exit code
This commit is contained in:
commit
2db059679b
@ -53,6 +53,9 @@ namespace Trick {
|
|||||||
/** Create test xml output.\n*/
|
/** Create test xml output.\n*/
|
||||||
bool enabled ; /**< trick_units(--) */
|
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*/
|
/** Name of Unit test\n*/
|
||||||
std::string name ;
|
std::string name ;
|
||||||
|
|
||||||
@ -77,6 +80,12 @@ namespace Trick {
|
|||||||
*/
|
*/
|
||||||
bool enable() ;
|
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.
|
@brief Output message to the file.
|
||||||
*/
|
*/
|
||||||
@ -96,6 +105,10 @@ namespace Trick {
|
|||||||
*/
|
*/
|
||||||
int set_file_name(std::string in_name) ;
|
int set_file_name(std::string in_name) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Write output to xml file.
|
||||||
|
@return always 0
|
||||||
|
*/
|
||||||
int write_output() ;
|
int write_output() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "trick/UnitTest.hh"
|
#include "trick/UnitTest.hh"
|
||||||
|
#include "trick/exec_proto.h"
|
||||||
#include "trick/message_proto.h"
|
#include "trick/message_proto.h"
|
||||||
#include "trick/message_type.h"
|
#include "trick/message_type.h"
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ void Trick::TestSuite::delete_test_results() {
|
|||||||
Trick::UnitTest::UnitTest() {
|
Trick::UnitTest::UnitTest() {
|
||||||
the_unit_test_output = this ;
|
the_unit_test_output = this ;
|
||||||
enabled = false ;
|
enabled = false ;
|
||||||
|
exit_code_enabled = false ;
|
||||||
file_name = std::string("test_details.xml") ;
|
file_name = std::string("test_details.xml") ;
|
||||||
name = std::string("AllTests") ;
|
name = std::string("AllTests") ;
|
||||||
}
|
}
|
||||||
@ -93,6 +95,11 @@ bool Trick::UnitTest::enable() {
|
|||||||
return(true) ;
|
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) {
|
int Trick::UnitTest::set_test_name(std::string in_name) {
|
||||||
name = in_name ;
|
name = in_name ;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
@ -149,6 +156,10 @@ int Trick::UnitTest::write_output() {
|
|||||||
out << " </testsuite>" << std::endl ;
|
out << " </testsuite>" << std::endl ;
|
||||||
}
|
}
|
||||||
out << "</testsuites>" << 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) ;
|
return(0) ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user