Debian Codegraph @

tests/TestScripts/testConfigureDisable.py

raw
1 #!/usr/bin/env python3
2
3 # Copyright Catch2 Authors
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE.txt or copy at
6 # https://www.boost.org/LICENSE_1_0.txt)
7
8 # SPDX-License-Identifier: BSL-1.0
9
10 from ConfigureTestsCommon import configure_and_build, run_and_return_output
11
12 import os
13 import re
14 import sys
15
16 """
17 Tests the CMake configure option for CATCH_CONFIG_DISABLE
18
19 Requires 2 arguments, path folder where the Catch2's main CMakeLists.txt
20 exists, and path to where the output files should be stored.
21 """
22
23 if len(sys.argv) != 3:
24 print('Wrong number of arguments: {}'.format(len(sys.argv)))
25 print('Usage: {} catch2-top-level-dir base-build-output-dir'.format(sys.argv[0]))
26 exit(1)
27
28 catch2_source_path = os.path.abspath(sys.argv[1])
29 build_dir_path = os.path.join(os.path.abspath(sys.argv[2]), 'CMakeConfigTests', 'Disable')
30
31 configure_and_build(catch2_source_path,
32 build_dir_path,
33 [("CATCH_CONFIG_DISABLE", "ON"),
34 # We need to turn off WERROR, because the compilers
35 # can see that the various variables inside test cases
36 # are set but unused.
37 ("CATCH_ENABLE_WERROR", "OFF")])
38
39 stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'),
40 'SelfTest',
41 ['--allow-running-no-tests'])
42
43
44 summary_line = 'No tests ran'
45 if not summary_line in stdout:
46 print("Could not find '{}' in the stdout".format(summary_line))
47 print('stdout: "{}"'.format(stdout))
48 exit(2)