Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/TestScripts
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-03-26 23:48:35 +0100
committerMartin Hořeňovský2024-03-27 10:03:51 +0100
commit7ce35799767de7b9c6ba836c72e479c5f70219a3 (patch)
tree57df1938c2e116e8fd00578250cfb496fdf5d673 /tests/TestScripts
parentc0dfe13bb6cb23b8127035ea8b5d1ca50fcf3693 (diff)
downloadcatch3-7ce35799767de7b9c6ba836c72e479c5f70219a3.tar.gz
Allow CATCH_CONFIG_DEFAULT_REPORTER to be arbitrary reporter spec
Previously it could be just plain reporter name, e.g. `xml`, but it could not specify other reporter options. This change is not particularly useful for the built-in reporters, as it mostly comes in handy for combining specific custom reporter with custom arguments, and the built-in reporters do not have those.
Diffstat (limited to 'tests/TestScripts')
-rw-r--r--tests/TestScripts/testConfigureDefaultReporter.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/TestScripts/testConfigureDefaultReporter.py b/tests/TestScripts/testConfigureDefaultReporter.py
index 5bf97871..119e1ca2 100644
--- a/tests/TestScripts/testConfigureDefaultReporter.py
+++ b/tests/TestScripts/testConfigureDefaultReporter.py
@@ -28,14 +28,23 @@ if len(sys.argv) != 3:
catch2_source_path = os.path.abspath(sys.argv[1])
build_dir_path = os.path.join(os.path.abspath(sys.argv[2]), 'CMakeConfigTests', 'DefaultReporter')
+output_file = f"{build_dir_path}/foo.xml"
+# We need to escape backslashes in Windows paths, because otherwise they
+# are interpreted as escape characters in strings, and cause compilation
+# error.
+escaped_output_file = output_file.replace('\\', '\\\\')
configure_and_build(catch2_source_path,
build_dir_path,
- [("CATCH_CONFIG_DEFAULT_REPORTER", "xml")])
+ [("CATCH_CONFIG_DEFAULT_REPORTER", f"xml::out={escaped_output_file}")])
stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'), 'SelfTest', ['[approx][custom]'])
-xml_tag = '</Catch2TestRun>'
-if xml_tag not in stdout:
- print("Could not find '{}' in the stdout".format(xml_tag))
- print('stdout: "{}"'.format(stdout))
+if not os.path.exists(output_file):
+ print(f'Did not find the {output_file} file')
exit(2)
+
+xml_tag = '</Catch2TestRun>'
+with open(output_file, 'r', encoding='utf-8') as file:
+ if xml_tag not in file.read():
+ print(f"Could not find '{xml_tag}' in the file")
+ exit(3)