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/>.
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
// Print out a summary of the relax test suite.
|
|
|
|
void summary(CppUnit::OStream &stream, int system_result, int unit_result, int gui_result, int simgear_result)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
// 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.
|
2018-03-28 15:30:59 +00:00
|
|
|
int status_gui=-1, status_simgear=-1, status_system=-1, status_unit=-1;
|
|
|
|
bool run_system=false, run_unit=false, run_gui=false, run_simgear=false;
|
2018-06-15 07:57:02 +00:00
|
|
|
bool verbose=false, ctest_output=false, debug=false, printSummary=true, help=false;
|
2018-03-28 15:30:59 +00:00
|
|
|
char *subset_system=NULL, *subset_unit=NULL, *subset_gui=NULL, *subset_simgear=NULL;
|
|
|
|
char firstchar;
|
|
|
|
std::string fgRoot;
|
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';
|
|
|
|
if (i < argc-1)
|
|
|
|
firstchar = argv[i+1][0];
|
|
|
|
|
|
|
|
// System test.
|
|
|
|
if (strcmp(argv[i], "-s") == 0 || strcmp(argv[i], "--system-tests") == 0) {
|
|
|
|
run_system = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_system = argv[i+1];
|
|
|
|
|
|
|
|
// Unit test.
|
|
|
|
} else if (strcmp(argv[i], "-u") == 0 || strcmp(argv[i], "--unit-tests") == 0) {
|
|
|
|
run_unit = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_unit = argv[i+1];
|
|
|
|
|
|
|
|
// GUI test.
|
|
|
|
} else if (strcmp(argv[i], "-g") == 0 || strcmp(argv[i], "--gui-tests") == 0) {
|
|
|
|
run_gui = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_gui = argv[i+1];
|
|
|
|
|
|
|
|
// Simgear test.
|
|
|
|
} else if (strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "--simgear-tests") == 0) {
|
|
|
|
run_simgear = true;
|
|
|
|
if (firstchar != '-')
|
|
|
|
subset_simgear = argv[i+1];
|
|
|
|
|
|
|
|
// Verbose output.
|
|
|
|
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
|
|
|
|
verbose = true;
|
|
|
|
|
2018-03-12 10:43:24 +00:00
|
|
|
// CTest suitable output.
|
|
|
|
} else if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--ctest") == 0) {
|
|
|
|
ctest_output = true;
|
|
|
|
|
2018-03-12 15:43:24 +00:00
|
|
|
// Debug output.
|
|
|
|
} else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--debug") == 0) {
|
|
|
|
debug = true;
|
|
|
|
|
2018-06-15 07:57:02 +00:00
|
|
|
// No summary output.
|
|
|
|
} else if (strcmp(argv[i], "--no-summary") == 0) {
|
|
|
|
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.
|
|
|
|
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
|
|
|
help = true;
|
2018-03-28 15:30:59 +00:00
|
|
|
|
|
|
|
// FGData path.
|
|
|
|
} else if (strcmp(argv[i], "--fg-root") == 0) {
|
|
|
|
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) {
|
|
|
|
std::cout << "Usage: run_test_suite [options]" << std::endl << std::endl;
|
|
|
|
std::cout << "Options:" << std::endl;
|
|
|
|
std::cout << " -h, --help show this help message and exit." << std::endl;
|
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << " Test selection options:" << std::endl;
|
|
|
|
std::cout << " -s, --system-tests execute the system/functional tests." << std::endl;
|
|
|
|
std::cout << " -u, --unit-tests execute the unit tests." << std::endl;
|
|
|
|
std::cout << " -g, --gui-tests execute the GUI tests." << std::endl;
|
|
|
|
std::cout << " -m, --simgear-tests execute the simgear tests." << std::endl;
|
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << " The -s, -u, -g, and -m options accept an optional argument to perform a" << std::endl;
|
|
|
|
std::cout << " subset of all tests. This argument should either be the name of a test" << std::endl;
|
|
|
|
std::cout << " suite or the full name of an individual test." << std::endl;
|
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << " Full test names consist of the test suite name, the separator '::' and then" << std::endl;
|
|
|
|
std::cout << " the individual test name. The test names can revealed with the verbose" << std::endl;
|
|
|
|
std::cout << " option." << std::endl;
|
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << " Verbosity options:" << std::endl;
|
|
|
|
std::cout << " -v, --verbose verbose output including names and timings for all" << std::endl;
|
|
|
|
std::cout << " tests." << std::endl;
|
2018-03-12 10:43:24 +00:00
|
|
|
std::cout << " -c, --ctest simplified output suitable for running via CTest." << std::endl;
|
2018-03-12 15:43:24 +00:00
|
|
|
std::cout << " -d, --debug disable IO capture for debugging (super verbose output)." << std::endl;
|
2018-06-15 07:57:02 +00:00
|
|
|
std::cout << " --no-summary disable the final summary printout." << std::endl;
|
2018-03-28 15:30:59 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << " FG options:" << std::endl;
|
|
|
|
std::cout << " --fg-root the path to FGData" << std::endl;
|
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
|
|
|
std::cout.flush();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Turn on all tests if no subset was specified.
|
|
|
|
if (!run_system && !run_unit && !run_gui && !run_simgear) {
|
|
|
|
run_system = true;
|
|
|
|
run_unit = true;
|
|
|
|
run_gui = true;
|
|
|
|
run_simgear = true;
|
|
|
|
}
|
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)
|
|
|
|
sglog().setLogLevels(SG_ALL, SG_BULK);
|
|
|
|
else
|
|
|
|
setupLogging();
|
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)
|
2018-06-20 09:29:29 +00:00
|
|
|
status_system = testRunner("System tests", "System / functional tests", subset_system, verbose, 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)
|
2018-06-20 09:29:29 +00:00
|
|
|
status_unit = testRunner("Unit tests", "Unit tests", subset_unit, verbose, ctest_output, debug);
|
|
|
|
if (run_gui && 0) // Disabled as there are no GUI tests yet.
|
|
|
|
status_gui = testRunner("GUI tests", "GUI tests", subset_gui, verbose, 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)
|
2018-06-20 09:29:29 +00:00
|
|
|
status_simgear = testRunner("Simgear unit tests", "Simgear unit tests", subset_simgear, verbose, 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)
|
2018-03-12 10:43:24 +00:00
|
|
|
summary(cerr, status_system, status_unit, status_gui, status_simgear);
|
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;
|
|
|
|
|
|
|
|
// Success.
|
|
|
|
return 0;
|
|
|
|
}
|