testConfigureDisableStringification.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_DISABLE_STRINGIFICATION
  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', 'DisableStringification')
  22. configure_and_build(catch2_source_path,
  23. build_dir_path,
  24. [("CATCH_CONFIG_DISABLE_STRINGIFICATION", "ON")])
  25. stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'),
  26. 'SelfTest',
  27. ['-s', '[approx][custom]'])
  28. required_output = 'Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION'
  29. if not required_output in stdout:
  30. print("Could not find '{}' in the stdout".format(required_output))
  31. print('stdout: "{}"'.format(stdout))
  32. exit(2)