23 using namespace clara;
25 auto const setWarning = [&]( std::string
const& warning ) {
26 auto warningSet = [&]() {
27 if( warning ==
"NoAssertions" )
30 if ( warning ==
"NoTests" )
41 auto const loadTestNamesFromFile = [&]( std::string
const& filename ) {
42 std::ifstream
f( filename.c_str() );
47 while( std::getline(
f, line ) ) {
49 if( !line.empty() && !
startsWith( line,
'#' ) ) {
51 line =
'"' + line +
'"';
52 config.testsOrTags.push_back( line +
',' );
57 auto const setTestOrder = [&]( std::string
const& order ) {
68 auto const setRngSeed = [&]( std::string
const& seed ) {
71 config.rngSeed =
static_cast<unsigned int>( std::time(
nullptr) );
74 auto const setColourUsage = [&]( std::string
const& useColour ) {
75 auto mode =
toLower( useColour );
79 else if( mode ==
"no" )
81 else if( mode ==
"auto" )
87 auto const setWaitForKeypress = [&]( std::string
const& keypress ) {
88 auto keypressLc =
toLower( keypress );
89 if( keypressLc ==
"start" )
91 else if( keypressLc ==
"exit" )
93 else if( keypressLc ==
"both" )
96 return ParserResult::runtimeError(
"keypress argument must be one of: start, exit or both. '" + keypress +
"' not recognised" );
99 auto const setVerbosity = [&]( std::string
const& verbosity ) {
100 auto lcVerbosity =
toLower( verbosity );
101 if( lcVerbosity ==
"quiet" )
103 else if( lcVerbosity ==
"normal" )
105 else if( lcVerbosity ==
"high" )
111 auto const setReporter = [&]( std::string
const& reporter ) {
114 auto lcReporter =
toLower( reporter );
115 auto result = factories.find( lcReporter );
117 if( factories.end() != result )
118 config.reporterName = lcReporter;
128 [
"-l"][
"--list-tests"]
129 (
"list all/matching test cases" )
131 [
"-t"][
"--list-tags"]
132 (
"list all/matching tags" )
135 (
"include successful tests in output" )
138 (
"break into debugger on failure" )
141 (
"skip exception tests" )
143 [
"-i"][
"--invisibles"]
144 (
"show invisibles (tabs, newlines)" )
145 |
Opt(
config.outputFilename,
"filename" )
147 (
"output filename" )
148 |
Opt( setReporter,
"name" )
150 (
"reporter to use (defaults to console)" )
154 |
Opt( [&](
bool ){
config.abortAfter = 1; } )
156 (
"abort at first failure" )
157 |
Opt( [&](
int x ){
config.abortAfter = x; },
"no. failures" )
159 (
"abort after x failures" )
160 |
Opt( setWarning,
"warning name" )
162 (
"enable warnings" )
164 [
"-d"][
"--durations"]
165 (
"show test durations" )
166 |
Opt( loadTestNamesFromFile,
"filename" )
167 [
"-f"][
"--input-file"]
168 (
"load test names to run from a file" )
170 [
"-#"][
"--filenames-as-tags"]
171 (
"adds a tag for the filename" )
172 |
Opt(
config.sectionsToRun,
"section name" )
174 (
"specify section to run" )
175 |
Opt( setVerbosity,
"quiet|normal|high" )
176 [
"-v"][
"--verbosity"]
177 (
"set output verbosity" )
179 [
"--list-test-names-only"]
180 (
"list all/matching test cases names only" )
183 (
"list all reporters" )
184 |
Opt( setTestOrder,
"decl|lex|rand" )
186 (
"test case order (defaults to decl)" )
187 |
Opt( setRngSeed,
"'time'|number" )
189 (
"set a specific seed for random numbers" )
190 |
Opt( setColourUsage,
"yes|no" )
192 (
"should output be colourised" )
195 (
"report name and version according to libidentify standard" )
196 |
Opt( setWaitForKeypress,
"start|exit|both" )
197 [
"--wait-for-keypress"]
198 (
"waits for a keypress before exiting" )
199 |
Opt(
config.benchmarkResolutionMultiple,
"multiplier" )
200 [
"--benchmark-resolution-multiple"]
201 (
"multiple of clock resolution to run benchmarks" )
203 |
Arg(
config.testsOrTags,
"test name|pattern|tags" )
204 (
"which test or tests to use" );