1 /* 2 * Created by Phil on 08/11/2010. 3 * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #ifndef TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED 9 #define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED 10 11 #include "catch_test_spec_parser.h" 12 #include "catch_interfaces_config.h" 13 14 // Libstdc++ doesn't like incomplete classes for unique_ptr 15 #include "catch_stream.h" 16 17 #include <memory> 18 #include <vector> 19 #include <string> 20 21 #ifndef CATCH_CONFIG_CONSOLE_WIDTH 22 #define CATCH_CONFIG_CONSOLE_WIDTH 80 23 #endif 24 25 namespace Catch { 26 27 struct IStream; 28 29 struct ConfigData { 30 bool listTests = false; 31 bool listTags = false; 32 bool listReporters = false; 33 bool listTestNamesOnly = false; 34 35 bool showSuccessfulTests = false; 36 bool shouldDebugBreak = false; 37 bool noThrow = false; 38 bool showHelp = false; 39 bool showInvisibles = false; 40 bool filenamesAsTags = false; 41 bool libIdentify = false; 42 43 int abortAfter = -1; 44 unsigned int rngSeed = 0; 45 int benchmarkResolutionMultiple = 100; 46 47 Verbosity verbosity = Verbosity::Normal; 48 WarnAbout::What warnings = WarnAbout::Nothing; 49 ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; 50 RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; 51 UseColour::YesOrNo useColour = UseColour::Auto; 52 WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; 53 54 std::string outputFilename; 55 std::string name; 56 std::string processName; 57 #ifndef CATCH_CONFIG_DEFAULT_REPORTER 58 #define CATCH_CONFIG_DEFAULT_REPORTER "console" 59 #endif 60 std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER; 61 #undef CATCH_CONFIG_DEFAULT_REPORTER 62 63 std::vector<std::string> testsOrTags; 64 std::vector<std::string> sectionsToRun; 65 }; 66 67 68 class Config : public IConfig { 69 public: 70 71 Config() = default; 72 Config( ConfigData const& data ); 73 virtual ~Config() = default; 74 75 std::string const& getFilename() const; 76 77 bool listTests() const; 78 bool listTestNamesOnly() const; 79 bool listTags() const; 80 bool listReporters() const; 81 82 std::string getProcessName() const; 83 std::string const& getReporterName() const; 84 85 std::vector<std::string> const& getTestsOrTags() const; 86 std::vector<std::string> const& getSectionsToRun() const override; 87 88 virtual TestSpec const& testSpec() const override; 89 bool hasTestFilters() const override; 90 91 bool showHelp() const; 92 93 // IConfig interface 94 bool allowThrows() const override; 95 std::ostream& stream() const override; 96 std::string name() const override; 97 bool includeSuccessfulResults() const override; 98 bool warnAboutMissingAssertions() const override; 99 bool warnAboutNoTests() const override; 100 ShowDurations::OrNot showDurations() const override; 101 RunTests::InWhatOrder runOrder() const override; 102 unsigned int rngSeed() const override; 103 int benchmarkResolutionMultiple() const override; 104 UseColour::YesOrNo useColour() const override; 105 bool shouldDebugBreak() const override; 106 int abortAfter() const override; 107 bool showInvisibles() const override; 108 Verbosity verbosity() const override; 109 110 private: 111 112 IStream const* openStream(); 113 ConfigData m_data; 114 115 std::unique_ptr<IStream const> m_stream; 116 TestSpec m_testSpec; 117 bool m_hasTestFilters = false; 118 }; 119 120 } // end namespace Catch 121 122 #endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED 123