mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
Support '-' as output path for stdout
This commit is contained in:
parent
4752545a69
commit
93882f7fab
@ -140,6 +140,8 @@ The JUnit reporter is an xml format that follows the structure of the JUnit XML
|
||||
|
||||
This option may be passed multiple times to use multiple (different) reporters at the same time. See [Reporters](reporters.md#multiple-reporters) for details.
|
||||
|
||||
As with the `--out` flag, `-` means writing to stdout.
|
||||
|
||||
_Note: There is currently no way to escape `::` in the reporter spec,
|
||||
and thus reporter/file names with `::` in them will not work properly.
|
||||
As `::` in paths is relatively obscure (unlike `:`), we do not consider
|
||||
@ -192,6 +194,11 @@ If one or more test-specs have been supplied too then only the matching tests wi
|
||||
|
||||
Use this option to send all output to a file. By default output is sent to stdout (note that uses of stdout and stderr *from within test cases* are redirected and included in the report - so even stderr will effectively end up on stdout).
|
||||
|
||||
Using `-` as the filename sends the output to stdout.
|
||||
|
||||
> Support for `-` as the filename was introduced in Catch2 X.Y.Z
|
||||
|
||||
|
||||
<a id="naming-a-test-run"></a>
|
||||
## Naming a test run
|
||||
<pre>-n, --name <name for test run></pre>
|
||||
|
@ -124,8 +124,9 @@ namespace Detail {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream const> {
|
||||
if( filename.empty() )
|
||||
if ( filename.empty() || filename == "-" ) {
|
||||
return Detail::make_unique<Detail::CoutStream>();
|
||||
}
|
||||
else if( filename[0] == '%' ) {
|
||||
if( filename == "%debug" )
|
||||
return Detail::make_unique<Detail::DebugOutStream>();
|
||||
|
@ -451,6 +451,26 @@ set_tests_properties("MultiReporter::NonCapturingReportersPropagateStdout"
|
||||
PASS_REGULAR_EXPRESSION "A string sent to stderr via clog"
|
||||
)
|
||||
|
||||
add_test(NAME "Outputs::DashAsOutLocationSendsOutputToStdout"
|
||||
COMMAND
|
||||
$<TARGET_FILE:SelfTest> "Factorials are computed"
|
||||
--out=-
|
||||
)
|
||||
set_tests_properties("Outputs::DashAsOutLocationSendsOutputToStdout"
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "All tests passed \\(5 assertions in 1 test case\\)"
|
||||
)
|
||||
|
||||
add_test(NAME "Reporters::DashAsLocationInReporterSpecSendsOutputToStdout"
|
||||
COMMAND
|
||||
$<TARGET_FILE:SelfTest> "Factorials are computed"
|
||||
--reporter console::-
|
||||
)
|
||||
set_tests_properties("Reporters::DashAsLocationInReporterSpecSendsOutputToStdout"
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "All tests passed \\(5 assertions in 1 test case\\)"
|
||||
)
|
||||
|
||||
|
||||
if (CATCH_USE_VALGRIND)
|
||||
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
|
||||
|
Loading…
Reference in New Issue
Block a user