catch_session.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Created by Phil on 31/10/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_RUNNER_HPP_INCLUDED
  9. #define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
  10. #include "catch_commandline.h"
  11. #include "catch_config.hpp"
  12. #include "catch_text.h"
  13. #include <memory>
  14. namespace Catch {
  15. class Session : NonCopyable {
  16. public:
  17. Session();
  18. ~Session() override;
  19. void showHelp() const;
  20. void libIdentify();
  21. int applyCommandLine( int argc, char const * const * argv );
  22. #if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE)
  23. int applyCommandLine( int argc, wchar_t const * const * argv );
  24. #endif
  25. void useConfigData( ConfigData const& configData );
  26. template<typename CharT>
  27. int run(int argc, CharT const * const argv[]) {
  28. if (m_startupExceptions)
  29. return 1;
  30. int returnCode = applyCommandLine(argc, argv);
  31. if (returnCode == 0)
  32. returnCode = run();
  33. return returnCode;
  34. }
  35. int run();
  36. clara::Parser const& cli() const;
  37. void cli( clara::Parser const& newParser );
  38. ConfigData& configData();
  39. Config& config();
  40. private:
  41. int runInternal();
  42. clara::Parser m_cli;
  43. ConfigData m_configData;
  44. std::shared_ptr<Config> m_config;
  45. bool m_startupExceptions = false;
  46. };
  47. } // end namespace Catch
  48. #endif // TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED