diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 34f50f1751..352c1f424a 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -107,14 +107,16 @@ namespace Catch { // Insert the default reporter if user hasn't asked for a specific one if ( m_data.reporterSpecifications.empty() ) { - m_data.reporterSpecifications.push_back( { #if defined( CATCH_CONFIG_DEFAULT_REPORTER ) - CATCH_CONFIG_DEFAULT_REPORTER, + const auto default_spec = CATCH_CONFIG_DEFAULT_REPORTER; #else - "console", + const auto default_spec = "console"; #endif - {}, {}, {} - } ); + auto parsed = parseReporterSpec(default_spec); + CATCH_ENFORCE( parsed, + "Cannot parse the provided default reporter spec: '" + << default_spec << '\'' ); + m_data.reporterSpecifications.push_back( std::move( *parsed ) ); } if ( enableBazelEnvSupport() ) { diff --git a/tests/TestScripts/testConfigureDefaultReporter.py b/tests/TestScripts/testConfigureDefaultReporter.py index 5bf9787122..c1c1c77d92 100644 --- a/tests/TestScripts/testConfigureDefaultReporter.py +++ b/tests/TestScripts/testConfigureDefaultReporter.py @@ -28,14 +28,20 @@ catch2_source_path = os.path.abspath(sys.argv[1]) build_dir_path = os.path.join(os.path.abspath(sys.argv[2]), 'CMakeConfigTests', 'DefaultReporter') +# TODO: incorporate build_dir_path in the output filename +output_file = f"{build_dir_path}/foo.xml" configure_and_build(catch2_source_path, build_dir_path, - [("CATCH_CONFIG_DEFAULT_REPORTER", "xml")]) + [("CATCH_CONFIG_DEFAULT_REPORTER", f"xml::out={output_file}")]) stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'), 'SelfTest', ['[approx][custom]']) -xml_tag = '' -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 = '' +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)