mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Allow test flags to be specified, so we don't need TEST_STRESS.
This commit is contained in:
parent
00ec14561b
commit
85a0c1c59f
4 changed files with 23 additions and 27 deletions
|
|
@ -69,23 +69,30 @@ class TorqueUnitTestListener : public ::testing::EmptyTestEventListener
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DefineConsoleFunction( runAllUnitTests, int, (bool includeStressTests), (false),
|
DefineConsoleFunction( runAllUnitTests, int, (const char* testSpecs), (""),
|
||||||
"Runs all engine unit tests. Some tests are marked as 'stress' tests which do "
|
"Runs engine unit tests. Some tests are marked as 'stress' tests which do not "
|
||||||
"not necessarily check correctness, just performance or possible nondeterministic "
|
"necessarily check correctness, just performance or possible nondeterministic "
|
||||||
"glitches. These tests can take some time, so they are not included unless "
|
"glitches. There may also be interactive or networking tests which may be "
|
||||||
"specified.\n\n"
|
"excluded by using the testSpecs argument.\n"
|
||||||
"@param includeStressTests Run stress tests as well as unit tests. Default is false." )
|
"This function should only be called once per executable run, because of "
|
||||||
|
"googletest's design.\n\n"
|
||||||
|
|
||||||
|
"@param testSpecs A space-sepatated list of filters for test cases. "
|
||||||
|
"See https://code.google.com/p/googletest/wiki/AdvancedGuide#Running_a_Subset_of_the_Tests "
|
||||||
|
"for a description of the flag format.")
|
||||||
{
|
{
|
||||||
S32 testArgc = 0;
|
S32 testArgc = 0;
|
||||||
char** testArgv = NULL;
|
char** testArgv = NULL;
|
||||||
if ( includeStressTests )
|
if ( dStrlen( testSpecs ) > 0 )
|
||||||
{
|
{
|
||||||
// Yes, I never free this memory, because it seems to be mangled by gtest.
|
String specs(testSpecs);
|
||||||
// Also it's a negligible space leak that will only occur once.
|
specs.replace(' ', ':');
|
||||||
|
specs.insert(0, "--gtest_filter=");
|
||||||
|
testArgc = 2;
|
||||||
testArgv = new char*[2];
|
testArgv = new char*[2];
|
||||||
testArgv[0] = new char( '\0' );
|
testArgv[0] = NULL; // Program name is unused by googletest.
|
||||||
testArgv[1] = new char[26];
|
testArgv[1] = new char[specs.length()+1];
|
||||||
dStrcpy( testArgv[1], "--gtest_filter=-*Stress.*" );
|
dStrcpy(testArgv[1], specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Google Test.
|
// Initialize Google Test.
|
||||||
|
|
@ -108,11 +115,10 @@ DefineConsoleFunction( runAllUnitTests, int, (bool includeStressTests), (false),
|
||||||
// Add the Torque unit test listener.
|
// Add the Torque unit test listener.
|
||||||
listeners.Append( new TorqueUnitTestListener );
|
listeners.Append( new TorqueUnitTestListener );
|
||||||
|
|
||||||
|
// Perform googletest run.
|
||||||
Con::printf( "\nUnit Tests Starting...\n" );
|
Con::printf( "\nUnit Tests Starting...\n" );
|
||||||
|
|
||||||
const S32 result = RUN_ALL_TESTS();
|
const S32 result = RUN_ALL_TESTS();
|
||||||
|
Con::printf( "... Unit Tests Ended.\n" );
|
||||||
Con::printf( "\n... Unit Tests Ended.\n" );
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,16 +38,6 @@
|
||||||
GTEST_TEST_(test_fixture, test_name, test_fixture##Fixture, \
|
GTEST_TEST_(test_fixture, test_name, test_fixture##Fixture, \
|
||||||
::testing::internal::GetTypeId<test_fixture##Fixture>())
|
::testing::internal::GetTypeId<test_fixture##Fixture>())
|
||||||
|
|
||||||
/// Define a stress test. The test name is suffixed with Stress, so it will be
|
|
||||||
/// excluded from normal unit test runs.
|
|
||||||
#define TEST_STRESS(test_case_name, test_name)\
|
|
||||||
TEST(test_case_name##Stress, test_name)
|
|
||||||
|
|
||||||
/// Define a stress test with a fixture.
|
|
||||||
#define TEST_STRESS_FIX(test_fixture, test_name)\
|
|
||||||
GTEST_TEST_(test_fixture##Stress, test_name, test_fixture##Fixture, \
|
|
||||||
::testing::internal::GetTypeId<test_fixture##Fixture>())
|
|
||||||
|
|
||||||
#endif // TORQUE_TESTS_ENABLED
|
#endif // TORQUE_TESTS_ENABLED
|
||||||
|
|
||||||
#endif // _UNIT_TESTING_H_
|
#endif // _UNIT_TESTING_H_
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
setLogMode(2);
|
setLogMode(2);
|
||||||
$Con::LogBufferEnabled = false;
|
$Con::LogBufferEnabled = false;
|
||||||
$Testing::CheckMemoryLeaks = false;
|
$Testing::CheckMemoryLeaks = false;
|
||||||
runAllUnitTests();
|
runAllUnitTests("-*.Stress*");
|
||||||
quit();
|
quit();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
setLogMode(2);
|
setLogMode(2);
|
||||||
$Con::LogBufferEnabled = false;
|
$Con::LogBufferEnabled = false;
|
||||||
$Testing::CheckMemoryLeaks = false;
|
$Testing::CheckMemoryLeaks = false;
|
||||||
runAllUnitTests();
|
runAllUnitTests("-*.Stress*");
|
||||||
quit();
|
quit();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue