diff --git a/docs/command-line.md b/docs/command-line.md
index 7ec2fbb3..dcc6a79a 100644
--- a/docs/command-line.md
+++ b/docs/command-line.md
@@ -271,7 +271,7 @@ See [The LibIdentify repo for more information and examples](https://github.com/
## Wait for key before continuing
-
--wait-for-keypress <start|exit|both>
+--wait-for-keypress <never|start|exit|both>
Will cause the executable to print a message and wait until the return/ enter key is pressed before continuing -
either before running any tests, after running all tests - or both, depending on the argument.
diff --git a/src/catch2/catch_commandline.cpp b/src/catch2/catch_commandline.cpp
index 3c453f48..6ed626a1 100644
--- a/src/catch2/catch_commandline.cpp
+++ b/src/catch2/catch_commandline.cpp
@@ -91,14 +91,16 @@ namespace Catch {
};
auto const setWaitForKeypress = [&]( std::string const& keypress ) {
auto keypressLc = toLower( keypress );
- if( keypressLc == "start" )
+ if (keypressLc == "never")
+ config.waitForKeypress = WaitForKeypress::Never;
+ else if( keypressLc == "start" )
config.waitForKeypress = WaitForKeypress::BeforeStart;
else if( keypressLc == "exit" )
config.waitForKeypress = WaitForKeypress::BeforeExit;
else if( keypressLc == "both" )
config.waitForKeypress = WaitForKeypress::BeforeStartAndExit;
else
- return ParserResult::runtimeError( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" );
+ return ParserResult::runtimeError( "keypress argument must be one of: never, start, exit or both. '" + keypress + "' not recognised" );
return ParserResult::ok( ParseResultType::Matched );
};
auto const setVerbosity = [&]( std::string const& verbosity ) {
@@ -195,7 +197,7 @@ namespace Catch {
| Opt( config.libIdentify )
["--libidentify"]
( "report name and version according to libidentify standard" )
- | Opt( setWaitForKeypress, "start|exit|both" )
+ | Opt( setWaitForKeypress, "never|start|exit|both" )
["--wait-for-keypress"]
( "waits for a keypress before exiting" )
| Opt( config.benchmarkSamples, "samples" )
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 66c48408..6524b8fd 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1124,6 +1124,16 @@ CmdLine.tests.cpp:: passed: cli.parse({"test", "-x", "2"}) for: {?}
CmdLine.tests.cpp:: passed: config.abortAfter == 2 for: 2 == 2
CmdLine.tests.cpp:: passed: !result for: true
CmdLine.tests.cpp:: passed: result.errorMessage(), Contains("convert") && Contains("oops") for: "Unable to convert 'oops' to destination type" ( contains: "convert" and contains: "oops" )
+CmdLine.tests.cpp:: passed: cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+CmdLine.tests.cpp:: passed: config.waitForKeypress == std::get<1>(input) for: 0 == 0
+CmdLine.tests.cpp:: passed: cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+CmdLine.tests.cpp:: passed: config.waitForKeypress == std::get<1>(input) for: 1 == 1
+CmdLine.tests.cpp:: passed: cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+CmdLine.tests.cpp:: passed: config.waitForKeypress == std::get<1>(input) for: 2 == 2
+CmdLine.tests.cpp:: passed: cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+CmdLine.tests.cpp:: passed: config.waitForKeypress == std::get<1>(input) for: 3 == 3
+CmdLine.tests.cpp:: passed: !result for: true
+CmdLine.tests.cpp:: passed: result.errorMessage(), Contains("never") && Contains("both") for: "keypress argument must be one of: never, start, exit or both. 'sometimes' not recognised" ( contains: "never" and contains: "both" )
CmdLine.tests.cpp:: passed: cli.parse({"test", "-e"}) for: {?}
CmdLine.tests.cpp:: passed: config.noThrow for: true
CmdLine.tests.cpp:: passed: cli.parse({"test", "--nothrow"}) for: {?}
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index a0603ad8..36d6dd94 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1381,5 +1381,5 @@ due to unexpected exception with message:
===============================================================================
test cases: 329 | 255 passed | 70 failed | 4 failed as expected
-assertions: 1831 | 1679 passed | 131 failed | 21 failed as expected
+assertions: 1841 | 1689 passed | 131 failed | 21 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 10eada63..0715ac7d 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -8072,6 +8072,102 @@ with expansion:
"Unable to convert 'oops' to destination type" ( contains: "convert" and
contains: "oops" )
+-------------------------------------------------------------------------------
+Process can be configured on command line
+ abort
+ wait-for-keypress
+ Accepted options
+-------------------------------------------------------------------------------
+CmdLine.tests.cpp:
+...............................................................................
+
+CmdLine.tests.cpp:: PASSED:
+ CHECK( cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) )
+with expansion:
+ {?}
+
+CmdLine.tests.cpp:: PASSED:
+ REQUIRE( config.waitForKeypress == std::get<1>(input) )
+with expansion:
+ 0 == 0
+
+-------------------------------------------------------------------------------
+Process can be configured on command line
+ abort
+ wait-for-keypress
+ Accepted options
+-------------------------------------------------------------------------------
+CmdLine.tests.cpp:
+...............................................................................
+
+CmdLine.tests.cpp:: PASSED:
+ CHECK( cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) )
+with expansion:
+ {?}
+
+CmdLine.tests.cpp:: PASSED:
+ REQUIRE( config.waitForKeypress == std::get<1>(input) )
+with expansion:
+ 1 == 1
+
+-------------------------------------------------------------------------------
+Process can be configured on command line
+ abort
+ wait-for-keypress
+ Accepted options
+-------------------------------------------------------------------------------
+CmdLine.tests.cpp:
+...............................................................................
+
+CmdLine.tests.cpp:: PASSED:
+ CHECK( cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) )
+with expansion:
+ {?}
+
+CmdLine.tests.cpp:: PASSED:
+ REQUIRE( config.waitForKeypress == std::get<1>(input) )
+with expansion:
+ 2 == 2
+
+-------------------------------------------------------------------------------
+Process can be configured on command line
+ abort
+ wait-for-keypress
+ Accepted options
+-------------------------------------------------------------------------------
+CmdLine.tests.cpp:
+...............................................................................
+
+CmdLine.tests.cpp:: PASSED:
+ CHECK( cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) )
+with expansion:
+ {?}
+
+CmdLine.tests.cpp:: PASSED:
+ REQUIRE( config.waitForKeypress == std::get<1>(input) )
+with expansion:
+ 3 == 3
+
+-------------------------------------------------------------------------------
+Process can be configured on command line
+ abort
+ wait-for-keypress
+ invalid options are reported
+-------------------------------------------------------------------------------
+CmdLine.tests.cpp:
+...............................................................................
+
+CmdLine.tests.cpp:: PASSED:
+ CHECK( !result )
+with expansion:
+ true
+
+CmdLine.tests.cpp:: PASSED:
+ REQUIRE_THAT( result.errorMessage(), Contains("never") && Contains("both") )
+with expansion:
+ "keypress argument must be one of: never, start, exit or both. 'sometimes'
+ not recognised" ( contains: "never" and contains: "both" )
+
-------------------------------------------------------------------------------
Process can be configured on command line
nothrow
@@ -14319,5 +14415,5 @@ Misc.tests.cpp:: PASSED:
===============================================================================
test cases: 329 | 239 passed | 86 failed | 4 failed as expected
-assertions: 1848 | 1679 passed | 148 failed | 21 failed as expected
+assertions: 1858 | 1689 passed | 148 failed | 21 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index b10151f1..e5b297ef 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
-
+
@@ -1013,6 +1013,8 @@ Message.tests.cpp:
+
+
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 1b446e04..ee917244 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -52,6 +52,8 @@
+
+
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 9e366479..58869cfb 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -2171,6 +2171,26 @@ ok {test-number} - !result for: true
# Process can be configured on command line
ok {test-number} - result.errorMessage(), Contains("convert") && Contains("oops") for: "Unable to convert 'oops' to destination type" ( contains: "convert" and contains: "oops" )
# Process can be configured on command line
+ok {test-number} - cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+# Process can be configured on command line
+ok {test-number} - config.waitForKeypress == std::get<1>(input) for: 0 == 0
+# Process can be configured on command line
+ok {test-number} - cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+# Process can be configured on command line
+ok {test-number} - config.waitForKeypress == std::get<1>(input) for: 1 == 1
+# Process can be configured on command line
+ok {test-number} - cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+# Process can be configured on command line
+ok {test-number} - config.waitForKeypress == std::get<1>(input) for: 2 == 2
+# Process can be configured on command line
+ok {test-number} - cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}) for: {?}
+# Process can be configured on command line
+ok {test-number} - config.waitForKeypress == std::get<1>(input) for: 3 == 3
+# Process can be configured on command line
+ok {test-number} - !result for: true
+# Process can be configured on command line
+ok {test-number} - result.errorMessage(), Contains("never") && Contains("both") for: "keypress argument must be one of: never, start, exit or both. 'sometimes' not recognised" ( contains: "never" and contains: "both" )
+# Process can be configured on command line
ok {test-number} - cli.parse({"test", "-e"}) for: {?}
# Process can be configured on command line
ok {test-number} - config.noThrow for: true
@@ -3688,5 +3708,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..1840
+1..1850
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index 63f6d760..3caf2c19 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -10092,6 +10092,131 @@ Nor would this
+
+
+
+
+
+ cli.parse({"test", "--wait-for-keypress", std::get<0>(input)})
+
+
+ {?}
+
+
+
+
+ config.waitForKeypress == std::get<1>(input)
+
+
+ 0 == 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cli.parse({"test", "--wait-for-keypress", std::get<0>(input)})
+
+
+ {?}
+
+
+
+
+ config.waitForKeypress == std::get<1>(input)
+
+
+ 1 == 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cli.parse({"test", "--wait-for-keypress", std::get<0>(input)})
+
+
+ {?}
+
+
+
+
+ config.waitForKeypress == std::get<1>(input)
+
+
+ 2 == 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cli.parse({"test", "--wait-for-keypress", std::get<0>(input)})
+
+
+ {?}
+
+
+
+
+ config.waitForKeypress == std::get<1>(input)
+
+
+ 3 == 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+ !result
+
+
+ true
+
+
+
+
+ result.errorMessage(), Contains("never") && Contains("both")
+
+
+ "keypress argument must be one of: never, start, exit or both. 'sometimes' not recognised" ( contains: "never" and contains: "both" )
+
+
+
+
+
+
+
+
@@ -17158,7 +17283,7 @@ loose text artifact
-
+
-
+
diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
index b7d5c9c2..2d62e9e1 100644
--- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#ifdef __clang__
# pragma clang diagnostic ignored "-Wc++98-compat"
@@ -410,7 +411,31 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
CHECK(!result);
REQUIRE_THAT(result.errorMessage(), Contains("convert") && Contains("oops"));
}
+
+ SECTION("wait-for-keypress") {
+ SECTION("Accepted options") {
+ using tuple_type = std::tuple;
+ auto input = GENERATE(table({
+ tuple_type{"never", Catch::WaitForKeypress::Never},
+ tuple_type{"start", Catch::WaitForKeypress::BeforeStart},
+ tuple_type{"exit", Catch::WaitForKeypress::BeforeExit},
+ tuple_type{"both", Catch::WaitForKeypress::BeforeStartAndExit},
+ }));
+ CHECK(cli.parse({"test", "--wait-for-keypress", std::get<0>(input)}));
+
+ REQUIRE(config.waitForKeypress == std::get<1>(input));
+ }
+
+ SECTION("invalid options are reported") {
+ auto result = cli.parse({"test", "--wait-for-keypress", "sometimes"});
+ CHECK(!result);
+
+#ifndef CATCH_CONFIG_DISABLE_MATCHERS
+ REQUIRE_THAT(result.errorMessage(), Contains("never") && Contains("both"));
+#endif
+ }
}
+ }
SECTION("nothrow") {
SECTION("-e") {