-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default reporter for Bazel integration
When the added Bazel configuration flag is enabled, a default JUnit reporter will be added if the XML envrioment variable is defined. Fix include paths for generated config header. Enable Bazel config by default when building with Bazel.
- Loading branch information
1 parent
0e176c3
commit b404700
Showing
6 changed files
with
146 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright Catch2 Authors | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# (See accompanying file LICENSE_1_0.txt or copy at | ||
# https://www.boost.org/LICENSE_1_0.txt) | ||
|
||
# SPDX-License-Identifier: BSL-1.0 | ||
|
||
from ConfigureTestsCommon import configure_and_build, run_and_return_output | ||
|
||
import os | ||
import re | ||
import sys | ||
import xml.etree.ElementTree as ET | ||
|
||
""" | ||
Tests the CMake configure option for CATCH_CONFIG_DEFAULT_REPORTER | ||
Requires 2 arguments, path folder where the Catch2's main CMakeLists.txt | ||
exists, and path to where the output files should be stored. | ||
""" | ||
if len(sys.argv) != 3: | ||
print("Wrong number of arguments: {}".format(len(sys.argv))) | ||
print("Usage: {} catch2-top-level-dir base-build-output-dir".format(sys.argv[0])) | ||
exit(1) | ||
|
||
catch2_source_path = os.path.abspath(sys.argv[1]) | ||
build_dir_path = os.path.join( | ||
os.path.abspath(sys.argv[2]), "CMakeConfigTests", "ConfigureBazelReporter" | ||
) | ||
|
||
configure_and_build( | ||
catch2_source_path, build_dir_path, [("CATCH_CONFIG_BAZEL_SUPPORT", "ON")] | ||
) | ||
|
||
xml_out_path = os.path.join( | ||
build_dir_path, | ||
"test.xml", | ||
) | ||
|
||
# Ensure no file exists from previous test runs | ||
if os.path.isfile(xml_out_path): | ||
os.remove(xml_out_path) | ||
|
||
|
||
os.environ["XML_OUTPUT_FILE"] = xml_out_path | ||
stdout, _ = run_and_return_output( | ||
os.path.join(build_dir_path, "tests"), | ||
"SelfTest", | ||
["-s", "[approx][custom]"], | ||
) | ||
|
||
try: | ||
tree = ET.parse(xml_out_path) | ||
except ET.ParseError as ex: | ||
print("Invalid XML: '{}'".format(ex)) | ||
raise | ||
except FileNotFoundError as ex: | ||
print("Could not find '{}'".format(xml_out_path)) | ||
raise | ||
|
||
testcases = tree.findall(".//testcase") | ||
if len(testcases) != 1: | ||
print( | ||
"Unexpected number of testcases '{}' in '{}'".format( | ||
len(testcases), xml_out_path | ||
) | ||
) | ||
exit(2) | ||
|
||
expected = { | ||
"classname": "SelfTest.global", | ||
"name": "Use a custom approx", | ||
"status": "run", | ||
} | ||
testcase = testcases[0] | ||
|
||
actual = testcase.attrib | ||
for expect_key, expect_val in expected.items(): | ||
if expect_key not in actual: | ||
print("Key not found in testcase tags: '{}'".format(expect_key)) | ||
exit(2) | ||
if expect_val != actual[expect_key]: | ||
print( | ||
"Value mismatch in testcase tags '{}' != '{}' for key '{}'".format( | ||
expect_val, actual[expect_key], expect_key | ||
) | ||
) | ||
exit(2) |