| 1 | /* |
| 2 | * Copyright (C) 2016 Edward d'Auvergne |
| 3 | * |
| 4 | * This file is part of the program FlightGear. |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #ifndef _FG_COMPILER_OUTPUTTER_HXX |
| 22 | #define _FG_COMPILER_OUTPUTTER_HXX |
| 23 | |
| 24 | |
| 25 | #include <cppunit/CompilerOutputter.h> |
| 26 | #include <cppunit/TestFailure.h> |
| 27 | |
| 28 | #include "fgTestListener.hxx" |
| 29 | |
| 30 | |
| 31 | // The custom outputter for the FlightGear test suite. |
| 32 | class fgCompilerOutputter : public CppUnit::CompilerOutputter |
| 33 | { |
| 34 | public: |
| 35 | // Constructor. |
| 36 | fgCompilerOutputter(CppUnit::TestResultCollector *result, |
| 37 | std::vector<TestIOCapt> *capt, |
| 38 | const clock_t *clock, |
| 39 | CppUnit::OStream &stream, |
| 40 | bool ctest = false, |
| 41 | bool debug = false, |
| 42 | const std::string &locationFormat = CPPUNIT_COMPILER_LOCATION_FORMAT) |
| 43 | : CppUnit::CompilerOutputter(result, stream, locationFormat) |
| 44 | , io_capt(capt) |
| 45 | , fg_result(result) |
| 46 | , fg_stream(stream) |
| 47 | , suite_timer(clock) |
| 48 | , ctest_output(ctest) |
| 49 | , debug(debug) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | // Create a new class instance. |
| 54 | static fgCompilerOutputter *defaultOutputter(CppUnit::TestResultCollector *result, std::vector<TestIOCapt> *capt, const clock_t *clock, CppUnit::OStream &stream); |
| 55 | |
| 56 | // Print a summary after a successful run of the test suite. |
| 57 | void printSuccess(); |
| 58 | |
| 59 | // Detailed printout after a failed run of the test suite. |
| 60 | void printFailureReport(); |
| 61 | |
| 62 | // Printout for each failed test. |
| 63 | void printFailureDetail(CppUnit::TestFailure *failure); |
| 64 | |
| 65 | // Printout of the test suite stats. |
| 66 | void printSuiteStats(); |
| 67 | |
| 68 | // The captured IO for each failed test. |
| 69 | std::vector<TestIOCapt> *io_capt; |
| 70 | |
| 71 | private: |
| 72 | // Store copies of the base class objects. |
| 73 | CppUnit::TestResultCollector *fg_result; |
| 74 | CppUnit::OStream &fg_stream; |
| 75 | |
| 76 | // The test suite time, in clock ticks. |
| 77 | const clock_t *suite_timer; |
| 78 | |
| 79 | // Output control. |
| 80 | bool ctest_output; |
| 81 | bool debug; |
| 82 | |
| 83 | // Simgear logstream IO printout. |
| 84 | void printIOStreamMessages(std::string heading, std::string messages, bool empty); |
| 85 | void printIOStreamMessages(std::string heading, std::string messages) {printIOStreamMessages(heading, messages, false);} |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | #endif // _FG_COMPILER_OUTPUTTER_HXX |