testConfigureDisable.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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
  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', 'Disable')
  22. configure_and_build(catch2_source_path,
  23. build_dir_path,
  24. [("CATCH_CONFIG_DISABLE", "ON"),
  25. # We need to turn off WERROR, because the compilers
  26. # can see that the various variables inside test cases
  27. # are set but unused.
  28. ("CATCH_ENABLE_WERROR", "OFF")])
  29. stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'),
  30. 'SelfTest',
  31. ['--allow-running-no-tests'])
  32. summary_line = 'No tests ran'
  33. if not summary_line in stdout:
  34. print("Could not find '{}' in the stdout".format(summary_line))
  35. print('stdout: "{}"'.format(stdout))
  36. exit(2)