catch_config.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #include "catch_test_spec_parser.h"
  11. #include "catch_interfaces_config.h"
  12. // Libstdc++ doesn't like incomplete classes for unique_ptr
  13. #include "catch_stream.h"
  14. #include <memory>
  15. #include <vector>
  16. #include <string>
  17. #ifndef CATCH_CONFIG_CONSOLE_WIDTH
  18. #define CATCH_CONFIG_CONSOLE_WIDTH 80
  19. #endif
  20. namespace Catch {
  21. struct IStream;
  22. struct ConfigData {
  23. bool listTests = false;
  24. bool listTags = false;
  25. bool listReporters = false;
  26. bool listTestNamesOnly = false;
  27. bool showSuccessfulTests = false;
  28. bool shouldDebugBreak = false;
  29. bool noThrow = false;
  30. bool showHelp = false;
  31. bool showInvisibles = false;
  32. bool filenamesAsTags = false;
  33. bool libIdentify = false;
  34. int abortAfter = -1;
  35. unsigned int rngSeed = 0;
  36. bool benchmarkNoAnalysis = false;
  37. unsigned int benchmarkSamples = 100;
  38. double benchmarkConfidenceInterval = 0.95;
  39. unsigned int benchmarkResamples = 100000;
  40. std::chrono::milliseconds::rep benchmarkWarmupTime = 100;
  41. Verbosity verbosity = Verbosity::Normal;
  42. WarnAbout::What warnings = WarnAbout::Nothing;
  43. ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
  44. double minDuration = -1;
  45. RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
  46. UseColour::YesOrNo useColour = UseColour::Auto;
  47. WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
  48. std::string outputFilename;
  49. std::string name;
  50. std::string processName;
  51. #ifndef CATCH_CONFIG_DEFAULT_REPORTER
  52. #define CATCH_CONFIG_DEFAULT_REPORTER "console"
  53. #endif
  54. std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER;
  55. #undef CATCH_CONFIG_DEFAULT_REPORTER
  56. std::vector<std::string> testsOrTags;
  57. std::vector<std::string> sectionsToRun;
  58. };
  59. class Config : public IConfig {
  60. public:
  61. Config() = default;
  62. Config( ConfigData const& data );
  63. virtual ~Config() = default;
  64. std::string const& getFilename() const;
  65. bool listTests() const;
  66. bool listTestNamesOnly() const;
  67. bool listTags() const;
  68. bool listReporters() const;
  69. std::string getProcessName() const;
  70. std::string const& getReporterName() const;
  71. std::vector<std::string> const& getTestsOrTags() const override;
  72. std::vector<std::string> const& getSectionsToRun() const override;
  73. TestSpec const& testSpec() const override;
  74. bool hasTestFilters() const override;
  75. bool showHelp() const;
  76. // IConfig interface
  77. bool allowThrows() const override;
  78. std::ostream& stream() const override;
  79. std::string name() const override;
  80. bool includeSuccessfulResults() const override;
  81. bool warnAboutMissingAssertions() const override;
  82. bool warnAboutNoTests() const override;
  83. ShowDurations::OrNot showDurations() const override;
  84. double minDuration() const override;
  85. RunTests::InWhatOrder runOrder() const override;
  86. unsigned int rngSeed() const override;
  87. UseColour::YesOrNo useColour() const override;
  88. bool shouldDebugBreak() const override;
  89. int abortAfter() const override;
  90. bool showInvisibles() const override;
  91. Verbosity verbosity() const override;
  92. bool benchmarkNoAnalysis() const override;
  93. int benchmarkSamples() const override;
  94. double benchmarkConfidenceInterval() const override;
  95. unsigned int benchmarkResamples() const override;
  96. std::chrono::milliseconds benchmarkWarmupTime() const override;
  97. private:
  98. IStream const* openStream();
  99. ConfigData m_data;
  100. std::unique_ptr<IStream const> m_stream;
  101. TestSpec m_testSpec;
  102. bool m_hasTestFilters = false;
  103. };
  104. } // end namespace Catch
  105. #endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED