testConfigureDefaultReporter.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python3
  2. # Copyright Catch2 Authors
  3. # Distributed under the Boost Software License, Version 1.0.
  4. # (See accompanying file LICENSE_1_0.txt or copy at
  5. # https://www.boost.org/LICENSE_1_0.txt)
  6. # SPDX-License-Identifier: BSL-1.0
  7. from ConfigureTestsCommon import configure_and_build, run_and_return_output
  8. import os
  9. import re
  10. import sys
  11. """
  12. Tests the CMake configure option for CATCH_CONFIG_DEFAULT_REPORTER
  13. Requires 2 arguments, path folder where the Catch2's main CMakeLists.txt
  14. exists, and path to where the output files should be stored.
  15. """
  16. if len(sys.argv) != 3:
  17. print('Wrong number of arguments: {}'.format(len(sys.argv)))
  18. print('Usage: {} catch2-top-level-dir base-build-output-dir'.format(sys.argv[0]))
  19. exit(1)
  20. catch2_source_path = os.path.abspath(sys.argv[1])
  21. build_dir_path = os.path.join(os.path.abspath(sys.argv[2]), 'CMakeConfigTests', 'DefaultReporter')
  22. configure_and_build(catch2_source_path,
  23. build_dir_path,
  24. [("CATCH_CONFIG_DEFAULT_REPORTER", "compact")])
  25. stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'), 'SelfTest', ['[approx][custom]'])
  26. # This matches the summary line made by compact reporter, console reporter's
  27. # summary line does not match the regex.
  28. summary_regex = 'Passed \d+ test case with \d+ assertions.'
  29. if not re.search(summary_regex, stdout):
  30. print("Could not find '{}' in the stdout".format(summary_regex))
  31. print('stdout: "{}"'.format(stdout))
  32. exit(2)