testConfigureExperimentalRedirect.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_EXPERIMENTAL_REDIRECT
  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', 'ExperimentalRedirect')
  22. configure_and_build(catch2_source_path,
  23. build_dir_path,
  24. [("CATCH_CONFIG_EXPERIMENTAL_REDIRECT", "ON")])
  25. stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'),
  26. 'SelfTest',
  27. ['-r', 'xml', '"has printf"'])
  28. # The print from printf must be within the XML's reporter stdout tag.
  29. required_output = '''\
  30. <StdOut>
  31. loose text artifact
  32. </StdOut>
  33. '''
  34. if not required_output in stdout:
  35. print("Could not find '{}' in the stdout".format(required_output))
  36. print('stdout: "{}"'.format(stdout))
  37. exit(2)