2016-01-28 15:56:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2018 Edward d'Auvergne
|
|
|
|
*
|
|
|
|
* This file is part of the program FlightGear.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-07-31 08:35:23 +00:00
|
|
|
#include <algorithm>
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
#include <cstring>
|
2016-01-28 15:56:10 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2018-03-28 15:30:59 +00:00
|
|
|
#include "dataStore.hxx"
|
2016-01-28 15:56:10 +00:00
|
|
|
#include "fgTestRunner.hxx"
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
#include "formatting.hxx"
|
2016-02-12 18:42:20 +00:00
|
|
|
#include "logging.hxx"
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
2019-08-07 09:21:42 +00:00
|
|
|
// The help message.
|
|
|
|
void helpPrintout(std::ostream &stream) {
|
|
|
|
stream << "Usage: run_test_suite [options]" << std::endl << std::endl;
|
|
|
|
stream << "Options:" << std::endl;
|
|
|
|
stream << " -h, --help show this help message and exit." << std::endl;
|
|
|
|
stream << std::endl;
|
|
|
|
stream << " Test selection options:" << std::endl;
|
|
|
|
stream << " -s, --system-tests execute the system/functional tests." << std::endl;
|
|
|
|
stream << " -u, --unit-tests execute the unit tests." << std::endl;
|
|
|
|
stream << " -g, --gui-tests execute the GUI tests." << std::endl;
|
|
|
|
stream << " -m, --simgear-tests execute the simgear tests." << std::endl;
|
|
|
|
stream << " -f, --fgdata-tests execute the FGData tests." << std::endl;
|
|
|
|
stream << std::endl;
|
|
|
|
stream << " The -s, -u, -g, and -m options accept an optional argument to perform a" << std::endl;
|
|
|
|
stream << " subset of all tests. This argument should either be the name of a test" << std::endl;
|
|
|
|
stream << " suite or the full name of an individual test." << std::endl;
|
|
|
|
stream << std::endl;
|
|
|
|
stream << " Full test names consist of the test suite name, the separator '::' and then" << std::endl;
|
|
|
|
stream << " the individual test name. The test names can revealed with the verbose" << std::endl;
|
|
|
|
stream << " option." << std::endl;
|
|
|
|
stream << std::endl;
|
|
|
|
stream << " Logging options:" << std::endl;
|
|
|
|
stream << " --log-level={bulk,debug,info,warn,alert,popup,dev_warn,dev_alert}" << std::endl;
|
|
|
|
stream << " specify the minimum logging level to output" << std::endl;
|
|
|
|
stream << " --log-class=[none, terrain, astro, flight, input, gl, view, cockpit," << std::endl;
|
|
|
|
stream << " general, math, event, aircraft, autopilot, io, clipper," << std::endl;
|
|
|
|
stream << " network, atc, nasal, instrumentation, systems, ai, environment," << std::endl;
|
|
|
|
stream << " sound, navaid, gui, terrasync, particles, headless, osg," << std::endl;
|
|
|
|
stream << " undefined, all]" << std::endl;
|
|
|
|
stream << " select the logging class(es) to output" << std::endl;
|
|
|
|
stream << " --log-split output the different non-interleaved log streams" << std::endl;
|
|
|
|
stream << " sequentially" << std::endl;
|
|
|
|
stream << std::endl;
|
|
|
|
stream << " Verbosity options:" << std::endl;
|
|
|
|
stream << " -t, --timings verbose output including names and timings for all" << std::endl;
|
|
|
|
stream << " tests." << std::endl;
|
|
|
|
stream << " -c, --ctest simplified output suitable for running via CTest." << std::endl;
|
|
|
|
stream << " -d, --debug disable IO capture for debugging (super verbose output)." << std::endl;
|
|
|
|
stream << " --no-summary disable the final summary printout." << std::endl;
|
|
|
|
stream << std::endl;
|
|
|
|
stream << " FG options:" << std::endl;
|
|
|
|
stream << " --fg-root the path to FGData" << std::endl;
|
2019-08-07 09:24:02 +00:00
|
|
|
stream << std::endl;
|
|
|
|
stream << "Environmental variables:" << std::endl;
|
|
|
|
stream << " FG_TEST_LOG_LEVEL equivalent to the --log-level option." << std::endl;
|
|
|
|
stream << " FG_TEST_LOG_CLASS equivalent to the --log-class option." << std::endl;
|
|
|
|
stream << " FG_TEST_LOG_SPLIT equivalent to the --log-split option." << std::endl;
|
|
|
|
stream << " FG_TEST_TIMINGS equivalent to the -t or --timings option." << std::endl;
|
|
|
|
stream << " FG_TEST_DEBUG equivalent to the -d or --debug option." << std::endl;
|
2019-08-07 09:21:42 +00:00
|
|
|
stream.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Convert the log class comma separated string list into a simgear debug class value.
|
|
|
|
sgDebugClass processLogClass(std::string classList, bool &failure) {
|
|
|
|
// Declarations.
|
|
|
|
std::string logClassItem, val;
|
|
|
|
unsigned int logClass=0;
|
|
|
|
|
|
|
|
// Convert the command line value into a string array.
|
|
|
|
std::replace(classList.begin(), classList.end(), ',', ' ');
|
|
|
|
std::vector<std::string> logClasses;
|
|
|
|
stringstream temp(classList);
|
|
|
|
while (temp >> val)
|
|
|
|
logClasses.push_back(val);
|
|
|
|
|
|
|
|
// Build up the value.
|
|
|
|
for (auto const& logClassItem: logClasses)
|
|
|
|
if (logClassItem == "none")
|
|
|
|
logClass |= SG_NONE;
|
|
|
|
else if (logClassItem == "terrain")
|
|
|
|
logClass |= SG_TERRAIN;
|
|
|
|
else if (logClassItem == "astro")
|
|
|
|
logClass |= SG_ASTRO;
|
|
|
|
else if (logClassItem == "flight")
|
|
|
|
logClass |= SG_FLIGHT;
|
|
|
|
else if (logClassItem == "input")
|
|
|
|
logClass |= SG_INPUT;
|
|
|
|
else if (logClassItem == "gl")
|
|
|
|
logClass |= SG_GL;
|
|
|
|
else if (logClassItem == "view")
|
|
|
|
logClass |= SG_VIEW;
|
|
|
|
else if (logClassItem == "cockpit")
|
|
|
|
logClass |= SG_COCKPIT;
|
|
|
|
else if (logClassItem == "general")
|
|
|
|
logClass |= SG_GENERAL;
|
|
|
|
else if (logClassItem == "math")
|
|
|
|
logClass |= SG_MATH;
|
|
|
|
else if (logClassItem == "event")
|
|
|
|
logClass |= SG_EVENT;
|
|
|
|
else if (logClassItem == "aircraft")
|
|
|
|
logClass |= SG_AIRCRAFT;
|
|
|
|
else if (logClassItem == "autopilot")
|
|
|
|
logClass |= SG_AUTOPILOT;
|
|
|
|
else if (logClassItem == "io")
|
|
|
|
logClass |= SG_IO;
|
|
|
|
else if (logClassItem == "clipper")
|
|
|
|
logClass |= SG_CLIPPER;
|
|
|
|
else if (logClassItem == "network")
|
|
|
|
logClass |= SG_NETWORK;
|
|
|
|
else if (logClassItem == "atc")
|
|
|
|
logClass |= SG_ATC;
|
|
|
|
else if (logClassItem == "nasal")
|
|
|
|
logClass |= SG_NASAL;
|
|
|
|
else if (logClassItem == "instrumentation")
|
|
|
|
logClass |= SG_INSTR;
|
|
|
|
else if (logClassItem == "systems")
|
|
|
|
logClass |= SG_SYSTEMS;
|
|
|
|
else if (logClassItem == "ai")
|
|
|
|
logClass |= SG_AI;
|
|
|
|
else if (logClassItem == "environment")
|
|
|
|
logClass |= SG_ENVIRONMENT;
|
|
|
|
else if (logClassItem == "sound")
|
|
|
|
logClass |= SG_SOUND;
|
|
|
|
else if (logClassItem == "navaid")
|
|
|
|
logClass |= SG_NAVAID;
|
|
|
|
else if (logClassItem == "gui")
|
|
|
|
logClass |= SG_GUI;
|
|
|
|
else if (logClassItem == "terrasync")
|
|
|
|
logClass |= SG_TERRASYNC;
|
|
|
|
else if (logClassItem == "particles")
|
|
|
|
logClass |= SG_PARTICLES;
|
|
|
|
else if (logClassItem == "headless")
|
|
|
|
logClass |= SG_HEADLESS;
|
|
|
|
else if (logClassItem == "osg")
|
|
|
|
logClass |= SG_OSG;
|
|
|
|
else if (logClassItem == "undefined")
|
|
|
|
logClass |= SG_UNDEFD;
|
|
|
|
else if (logClassItem == "all")
|
|
|
|
logClass |= SG_ALL;
|
|
|
|
else {
|
|
|
|
std::cout << "The log class \"" << logClassItem << "\" must be one of:" << std::endl;
|
|
|
|
std::cout << " {none, terrain, astro, flight, input, gl, view, cockpit, general, math," << std::endl;
|
|
|
|
std::cout << " event, aircraft, autopilot, io, clipper, network, atc, nasal," << std::endl;
|
|
|
|
std::cout << " instrumentation, systems, ai, environment, sound, navaid, gui, terrasync," << std::endl;
|
|
|
|
std::cout << " particles, headless, osg, undefined, all}" << std::endl << std::endl;
|
|
|
|
std::cout.flush();
|
|
|
|
failure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a simgear debug class.
|
|
|
|
return sgDebugClass(logClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Convert the log priority string into a simgear debug priority value.
|
|
|
|
sgDebugPriority processLogPriority(std::string logLevel, bool &failure) {
|
|
|
|
// Declarations.
|
|
|
|
sgDebugPriority logPriority=SG_INFO;
|
|
|
|
|
|
|
|
// Conversion.
|
|
|
|
if (logLevel == "bulk")
|
|
|
|
logPriority = SG_BULK;
|
|
|
|
else if (logLevel == "debug")
|
|
|
|
logPriority = SG_DEBUG;
|
|
|
|
else if (logLevel == "info")
|
|
|
|
logPriority = SG_INFO;
|
|
|
|
else if (logLevel == "warn")
|
|
|
|
logPriority = SG_WARN;
|
|
|
|
else if (logLevel == "alert")
|
|
|
|
logPriority = SG_ALERT;
|
|
|
|
else if (logLevel == "popup")
|
|
|
|
logPriority = SG_POPUP;
|
|
|
|
else if (logLevel == "dev_warn")
|
|
|
|
logPriority = SG_DEV_WARN;
|
|
|
|
else if (logLevel == "dev_alert")
|
|
|
|
logPriority = SG_DEV_ALERT;
|
|
|
|
else {
|
|
|
|
std::cout << "The log level setting of \"" << logLevel << "\" must be one of {bulk,debug,info,warn,alert,popup,dev_warn,dev_alert}.\n\n";
|
|
|
|
std::cout.flush();
|
|
|
|
failure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the simgear debug priority.
|
|
|
|
return logPriority;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
// Print out a summary of the relax test suite.
|
2019-09-13 09:51:20 +00:00
|
|
|
void summary(CppUnit::OStream &stream, int system_result, int unit_result, int gui_result, int simgear_result, int fgdata_result)
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
{
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
int synopsis = 0;
|
|
|
|
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
// Title.
|
|
|
|
string text = "Summary of the FlightGear test suite";
|
|
|
|
printTitle(stream, text);
|
|
|
|
|
|
|
|
// Subtitle.
|
|
|
|
text = "Synopsis";
|
|
|
|
printSection(stream, text);
|
|
|
|
|
|
|
|
// System/functional test summary.
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (system_result != -1) {
|
|
|
|
text = "System/functional tests";
|
|
|
|
printSummaryLine(stream, text, system_result);
|
|
|
|
synopsis += system_result;
|
|
|
|
}
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
|
|
|
|
// Unit test summary.
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (unit_result != -1) {
|
|
|
|
text = "Unit tests";
|
|
|
|
printSummaryLine(stream, text, unit_result);
|
|
|
|
synopsis += unit_result;
|
|
|
|
}
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
|
|
|
|
// GUI test summary.
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (gui_result != -1) {
|
|
|
|
text = "GUI tests";
|
|
|
|
printSummaryLine(stream, text, gui_result);
|
|
|
|
synopsis += gui_result;
|
|
|
|
}
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
|
|
|
|
// Simgear unit test summary.
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (simgear_result != -1) {
|
|
|
|
text = "Simgear unit tests";
|
|
|
|
printSummaryLine(stream, text, simgear_result);
|
|
|
|
synopsis += simgear_result;
|
|
|
|
}
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
|
2019-09-13 09:51:20 +00:00
|
|
|
// FGData test summary.
|
|
|
|
if (fgdata_result != -1) {
|
|
|
|
text = "FGData tests";
|
|
|
|
printSummaryLine(stream, text, fgdata_result);
|
|
|
|
synopsis += fgdata_result;
|
|
|
|
}
|
|
|
|
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
// Synopsis.
|
|
|
|
text ="Synopsis";
|
|
|
|
printSummaryLine(stream, text, synopsis);
|
|
|
|
|
|
|
|
// End.
|
|
|
|
stream << endl << endl;
|
|
|
|
}
|
2016-01-28 15:56:10 +00:00
|
|
|
|
|
|
|
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
int main(int argc, char **argv)
|
2016-01-28 15:56:10 +00:00
|
|
|
{
|
|
|
|
// Declarations.
|
2019-09-13 09:51:20 +00:00
|
|
|
int status_gui=-1, status_simgear=-1, status_system=-1, status_unit=-1, status_fgdata=-1;
|
|
|
|
bool run_system=false, run_unit=false, run_gui=false, run_simgear=false, run_fgdata=false;
|
2019-07-30 12:54:45 +00:00
|
|
|
bool logSplit=false;
|
2019-08-07 08:08:22 +00:00
|
|
|
bool timings=false, ctest_output=false, debug=false, printSummary=true, help=false;
|
2019-09-13 09:51:20 +00:00
|
|
|
char *subset_system=NULL, *subset_unit=NULL, *subset_gui=NULL, *subset_simgear=NULL, *subset_fgdata=NULL;
|
2019-08-07 09:21:42 +00:00
|
|
|
bool failure=false;
|
2018-03-28 15:30:59 +00:00
|
|
|
char firstchar;
|
2019-08-07 09:21:42 +00:00
|
|
|
std::string arg, delim, fgRoot, logClassVal, logLevel;
|
2019-07-30 11:19:23 +00:00
|
|
|
size_t delimPos;
|
|
|
|
|
2019-07-31 08:35:23 +00:00
|
|
|
// The default logging class and priority to show.
|
2019-08-07 09:21:42 +00:00
|
|
|
sgDebugClass logClass=SG_ALL;
|
2019-07-30 11:19:23 +00:00
|
|
|
sgDebugPriority logPriority=SG_INFO;
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
|
2019-08-07 09:24:02 +00:00
|
|
|
// Process environmental variables before the command line options.
|
|
|
|
if (getenv("FG_TEST_LOG_LEVEL"))
|
|
|
|
logPriority = processLogPriority(getenv("FG_TEST_LOG_LEVEL"), failure);
|
|
|
|
if (getenv("FG_TEST_LOG_CLASS"))
|
|
|
|
logClass = processLogClass(getenv("FG_TEST_LOG_CLASS"), failure);
|
|
|
|
if (getenv("FG_TEST_LOG_SPLIT"))
|
|
|
|
logSplit = true;
|
|
|
|
if (getenv("FG_TEST_TIMINGS"))
|
|
|
|
timings = true;
|
|
|
|
if (getenv("FG_TEST_DEBUG"))
|
|
|
|
debug = true;
|
|
|
|
if (failure)
|
|
|
|
return 1;
|
|
|
|
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
// Argument parsing.
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
firstchar = '\0';
|
2019-07-30 09:44:09 +00:00
|
|
|
arg = argv[i];
|
|
|
|
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (i < argc-1)
|
|
|
|
firstchar = argv[i+1][0];
|
|
|
|
|
|
|
|
// System test.
|
2019-07-30 09:44:09 +00:00
|
|
|
if (arg == "-s" || arg == "--system-tests") {
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
run_system = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_system = argv[i+1];
|
|
|
|
|
|
|
|
// Unit test.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "-u" || arg == "--unit-tests") {
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
run_unit = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_unit = argv[i+1];
|
|
|
|
|
|
|
|
// GUI test.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "-g" || arg == "--gui-tests") {
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
run_gui = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_gui = argv[i+1];
|
|
|
|
|
|
|
|
// Simgear test.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "-m" || arg == "--simgear-tests") {
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
run_simgear = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_simgear = argv[i+1];
|
|
|
|
|
2019-09-13 09:51:20 +00:00
|
|
|
// FGData test.
|
|
|
|
} else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--fgdata-tests") == 0) {
|
|
|
|
run_fgdata = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_fgdata = argv[i+1];
|
|
|
|
|
2019-07-31 08:35:23 +00:00
|
|
|
// Log class.
|
|
|
|
} else if (arg.find( "--log-class" ) == 0) {
|
|
|
|
// Process the command line.
|
|
|
|
logClass = SG_NONE;
|
|
|
|
delimPos = arg.find('=');
|
|
|
|
logClassVal = arg.substr(delimPos + 1);
|
2019-08-07 09:21:42 +00:00
|
|
|
logClass = processLogClass(logClassVal, failure);
|
|
|
|
if (failure)
|
|
|
|
return 1;
|
2019-07-31 08:35:23 +00:00
|
|
|
|
2019-07-30 11:19:23 +00:00
|
|
|
// Log level.
|
|
|
|
} else if (arg.find( "--log-level" ) == 0) {
|
|
|
|
// Process the command line level.
|
|
|
|
delimPos = arg.find('=');
|
|
|
|
logLevel = arg.substr(delimPos + 1);
|
2019-08-07 09:21:42 +00:00
|
|
|
logPriority = processLogPriority(logLevel, failure);
|
|
|
|
if (failure)
|
2019-07-30 11:19:23 +00:00
|
|
|
return 1;
|
|
|
|
|
2019-07-30 12:54:45 +00:00
|
|
|
// Log splitting.
|
|
|
|
} else if (arg == "--log-split") {
|
|
|
|
logSplit = true;
|
|
|
|
|
2019-08-07 08:08:22 +00:00
|
|
|
// Timing output.
|
|
|
|
} else if (arg == "-t" || arg == "--timings") {
|
|
|
|
timings = true;
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
|
2018-03-12 10:43:24 +00:00
|
|
|
// CTest suitable output.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "-c" || arg == "--ctest") {
|
2018-03-12 10:43:24 +00:00
|
|
|
ctest_output = true;
|
|
|
|
|
2018-03-12 15:43:24 +00:00
|
|
|
// Debug output.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "-d" || arg == "--debug") {
|
2018-03-12 15:43:24 +00:00
|
|
|
debug = true;
|
|
|
|
|
2018-06-15 07:57:02 +00:00
|
|
|
// No summary output.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "--no-summary") {
|
2018-06-15 07:57:02 +00:00
|
|
|
printSummary = false;
|
|
|
|
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
// Help.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "-h" || arg == "--help") {
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
help = true;
|
2018-03-28 15:30:59 +00:00
|
|
|
|
|
|
|
// FGData path.
|
2019-07-30 09:44:09 +00:00
|
|
|
} else if (arg == "--fg-root") {
|
2018-03-28 15:30:59 +00:00
|
|
|
if (firstchar != '-')
|
|
|
|
fgRoot = argv[i+1];
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Help.
|
|
|
|
if (help) {
|
2019-08-07 09:21:42 +00:00
|
|
|
helpPrintout(std::cout);
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Turn on all tests if no subset was specified.
|
2019-09-13 09:51:20 +00:00
|
|
|
if (!run_system && !run_unit && !run_gui && !run_simgear && !run_fgdata) {
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
run_system = true;
|
|
|
|
run_unit = true;
|
|
|
|
run_gui = true;
|
|
|
|
run_simgear = true;
|
2019-09-13 09:51:20 +00:00
|
|
|
run_fgdata = true;
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
}
|
2016-01-28 15:56:10 +00:00
|
|
|
|
2018-03-28 15:30:59 +00:00
|
|
|
// Set up the data store singleton and FGData path.
|
|
|
|
DataStore& data = DataStore::get();
|
|
|
|
if (data.findFGRoot(fgRoot, debug) != 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:42:20 +00:00
|
|
|
// Set up logging.
|
|
|
|
sglog().setDeveloperMode(true);
|
2018-03-12 15:43:24 +00:00
|
|
|
if (debug)
|
2019-07-31 08:35:23 +00:00
|
|
|
sglog().setLogLevels(sgDebugClass(logClass), logPriority);
|
2018-03-12 15:43:24 +00:00
|
|
|
else
|
2019-07-31 08:35:23 +00:00
|
|
|
setupLogging(sgDebugClass(logClass), logPriority, logSplit);
|
2016-02-12 18:42:20 +00:00
|
|
|
|
2016-01-28 15:56:10 +00:00
|
|
|
// Execute each of the test suite categories.
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (run_system)
|
2019-08-07 08:08:22 +00:00
|
|
|
status_system = testRunner("System tests", "System / functional tests", subset_system, timings, ctest_output, debug);
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (run_unit)
|
2019-08-07 08:08:22 +00:00
|
|
|
status_unit = testRunner("Unit tests", "Unit tests", subset_unit, timings, ctest_output, debug);
|
2018-06-20 09:29:29 +00:00
|
|
|
if (run_gui && 0) // Disabled as there are no GUI tests yet.
|
2019-08-07 08:08:22 +00:00
|
|
|
status_gui = testRunner("GUI tests", "GUI tests", subset_gui, timings, ctest_output, debug);
|
TestSuite: Addition of command line options for fine control of the executable.
This includes the following help message detailing all of the new options:
"""
Usage: run_test_suite [options]
Options:
-h, --help show this help message and exit.
Test selection options:
-s, --system-tests execute the system/functional tests.
-u, --unit-tests execute the unit tests.
-g, --gui-tests execute the GUI tests.
-m, --simgear-tests execute the simgear tests.
The -s, -u, -g, and -m options accept an optional argument to perform a
subset of all tests. This argument should either be the name of a test
suite or the full name of an individual test.
Full test names consist of the test suite name, the separator '::' and then
the individual test name. The test names can revealed with the verbose
option.
Verbosity options:
-v, --verbose verbose output including names and timings for all
tests.
"""
2018-03-09 23:02:14 +00:00
|
|
|
if (run_simgear)
|
2019-08-07 08:08:22 +00:00
|
|
|
status_simgear = testRunner("Simgear unit tests", "Simgear unit tests", subset_simgear, timings, ctest_output, debug);
|
2019-09-13 09:51:20 +00:00
|
|
|
if (run_fgdata)
|
2019-08-07 08:08:22 +00:00
|
|
|
status_fgdata = testRunner("FGData tests", "FGData tests", subset_fgdata, timings, ctest_output, debug);
|
2016-01-28 15:56:10 +00:00
|
|
|
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
// Summary printout.
|
2018-06-15 07:57:02 +00:00
|
|
|
if (printSummary && !ctest_output)
|
2019-09-13 09:51:20 +00:00
|
|
|
summary(cerr, status_system, status_unit, status_gui, status_simgear, status_fgdata);
|
TestSuite: Custom output formatting.
A large number of improvements have been made by subclassing the CppUnit classes
and overriding the base functions, including CompilerOutputter, TestListener,
and TextTestRunner. All IO has also been captured by the test runner.
The result is that during the test suite run, only the characters '.', 'F', and
'E' are output for a pass, failure and error state. At the end of each test
suite category, all failures and errors are reported in full detail, including
the different captured IO streams. A final synopsis is printed out, improving
the overview in the case of too many tests failing.
For the fgCompilerOutputter class, the printSuccess(), printFailureReport(),
printFailureDetail(), and printSuiteStats() functions have been replaced to
implement the above printout design. The class also stores the std::vector of
TestIOCapt structures for the final printouts.
The fgTestListener class handles the events from the running of the test suite.
The startTest() and endTest() functions are used for IO capture. The IO is
placed into a TestIOCapt data structure, with one std::string for holding the
combined STDOUT and STDERR IO, and another for the SG_LOG IO. If failures
occur, the TestIOCapt structure is appended to the fgCompilerOutputter vector.
The startTest() and endTest() functions are also used for starting and stopping
a timer to allow the full test suite to be timed. And the addFailure() function
simply registers test failures or errors.
The fgTestRunner class overrides the CppUnit::TextTestRunner::run() function,
simply to prevent the base method from spawning a second test listener, causing
the test output to be duplicated.
Some auxiliary formatting functions have been added to print out titles,
sections, and synopsis summary lines.
2016-02-09 16:34:56 +00:00
|
|
|
|
2016-02-12 18:42:20 +00:00
|
|
|
// Deactivate the logging.
|
2018-03-12 15:43:24 +00:00
|
|
|
if (!debug)
|
|
|
|
stopLogging();
|
2016-02-12 18:42:20 +00:00
|
|
|
|
2016-01-28 15:56:10 +00:00
|
|
|
// Failure.
|
|
|
|
if (status_system > 0)
|
|
|
|
return 1;
|
|
|
|
if (status_unit > 0)
|
|
|
|
return 1;
|
|
|
|
if (status_gui > 0)
|
|
|
|
return 1;
|
|
|
|
if (status_simgear > 0)
|
|
|
|
return 1;
|
2019-09-13 09:51:20 +00:00
|
|
|
if (status_fgdata > 0)
|
|
|
|
return 1;
|
2016-01-28 15:56:10 +00:00
|
|
|
|
|
|
|
// Success.
|
|
|
|
return 0;
|
|
|
|
}
|