Branch Coverage

Catch.xs
Criterion Covered Total %
branch 129 352 36.6


line true false branch
32 0 0 if (result.isOk()) printIssue(" # TODO");
0 0 if (result.isOk()) printIssue(" # TODO");
0 0 if (result.isOk()) printIssue(" # TODO");
36 0 0 printIssue("unexpected exception ");
0 0 printIssue("unexpected exception ");
41 0 0 printIssue("fatal error condition with message:");
0 0 printIssue("fatal error condition with message:");
47 0 0 printIssue("expected exception, got none");
0 0 printIssue("expected exception, got none");
62 0 0 printIssue("explicitly");
0 0 printIssue("explicitly");
77 3 132 while (pos < expr.length()) {
88 0 0 if (!result.hasExpression()) return;
94 50 0 if (result.hasExpression()) stream << " " << result.getExpression();
50 0 if (result.hasExpression()) stream << " " << result.getExpression();
50 0 if (result.hasExpression()) stream << " " << result.getExpression();
98 50 0 if (!result.hasExpandedExpression()) return;
17 33 if (!result.hasExpandedExpression()) return;
99 33 0 stream << " for: ";
100 33 0 string expr = result.getExpandedExpression();
102 33 0 expr_replace(expr, "\"\r\n==\r\n\"", "\" == \"");
33 0 expr_replace(expr, "\"\r\n==\r\n\"", "\" == \"");
33 0 expr_replace(expr, "\"\r\n==\r\n\"", "\" == \"");
103 33 0 expr_replace(expr, "\"\n==\n\"", "\" == \"");
33 0 expr_replace(expr, "\"\n==\n\"", "\" == \"");
33 0 expr_replace(expr, "\"\n==\n\"", "\" == \"");
105 33 0 expr_replace(expr, "\r", "\\r");
33 0 expr_replace(expr, "\r", "\\r");
33 0 expr_replace(expr, "\r", "\\r");
106 33 0 expr_replace(expr, "\n", "\\n");
33 0 expr_replace(expr, "\n", "\\n");
33 0 expr_replace(expr, "\n", "\\n");
107 33 0 stream << expr;
111 0 0 if (itMessage != messages.end()) {
118 50 0 if (itMessage == messages.cend()) return;
122 0 0 const size_t N = static_cast(std::distance(itMessage, itEnd));
124 0 0 stream << " with " << pluralise( N, "message" ) << ":";
0 0 stream << " with " << pluralise( N, "message" ) << ":";
0 0 stream << " with " << pluralise( N, "message" ) << ":";
126 0 0 for (; itMessage != itEnd; ++itMessage) {
128 0 0 if (itMessage->type != ResultWas::Info) {
129 0 0 stream << "\n# " << itMessage->message;
0 0 stream << "\n# " << itMessage->message;
141 0 5 struct PerlReporter : StreamingReporterBase {
142 5 0 struct Scope {
151 0 0 static string getDescription () { return "Reports test results in perl test-harness compatible format"; }
181 0 13 if (fatal) {
189 21 22 if (sliding_scope && sliding_scope->name == info.name) {
12 9 if (sliding_scope && sliding_scope->name == info.name) {
12 31 if (sliding_scope && sliding_scope->name == info.name) {
198 31 0 startLine();
199 18 13 auto fullname = scope->fullname.length() ? (scope->fullname + " / " + info.name) : info.name;
18 0 auto fullname = scope->fullname.length() ? (scope->fullname + " / " + info.name) : info.name;
18 0 auto fullname = scope->fullname.length() ? (scope->fullname + " / " + info.name) : info.name;
13 0 auto fullname = scope->fullname.length() ? (scope->fullname + " / " + info.name) : info.name;
18 13 auto fullname = scope->fullname.length() ? (scope->fullname + " / " + info.name) : info.name;
0 0 auto fullname = scope->fullname.length() ? (scope->fullname + " / " + info.name) : info.name;
200 31 0 m_stream << "# Subtest: " << fullname << endl;
31 0 m_stream << "# Subtest: " << fullname << endl;
31 0 m_stream << "# Subtest: " << fullname << endl;
201 31 0 scopes.push_back({0, 0, scope->depth + 1, info.name, fullname});
31 0 scopes.push_back({0, 0, scope->depth + 1, info.name, fullname});
31 0 scopes.push_back({0, 0, scope->depth + 1, info.name, fullname});
206 0 43 if (fatal) return;
207 22 21 if (!sliding_scope) sliding_scope = scope + 1;
209 22 21 if (sliding_scope == &scopes[1]) commitAssertions();
213 22 22 if (!sliding_scope) return;
215 31 22 while (cnt--) closeCurrentScope();
220 31 0 auto name = scope->fullname;
222 31 0 startLine() << "1.." << scope->count << endl;
31 0 startLine() << "1.." << scope->count << endl;
31 0 startLine() << "1.." << scope->count << endl;
31 0 startLine() << "1.." << scope->count << endl;
223 0 31 if (scope->failed) {
224 0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
0 0 startErrorLine() << "# Looks like you failed " << scope->failed << " test of " << scope->count << " at [" << name << "]." << endl;
228 0 31 if (scopes.empty()) throw "WTF?";
232 31 0 startLine();
233 0 31 if (failed) {
235 0 0 m_stream << "not ok";
237 31 0 else m_stream << "ok";
238 31 0 m_stream << " " << scope->count << " - [" << name << "]" << endl;
31 0 m_stream << " " << scope->count << " - [" << name << "]" << endl;
31 0 m_stream << " " << scope->count << " - [" << name << "]" << endl;
31 0 m_stream << " " << scope->count << " - [" << name << "]" << endl;
31 0 m_stream << " " << scope->count << " - [" << name << "]" << endl;
31 0 m_stream << " " << scope->count << " - [" << name << "]" << endl;
242 353 143 for (size_t i = 0; i < scope->depth; ++i) m_stream << " ";
247 0 0 for (size_t i = 0; i < scope->depth; ++i) std::cerr << " ";
254 50 0 ostringstream s;
255 50 0 Printer(s, stats).print();
50 0 Printer(s, stats).print();
256 50 0 assertions.push_back({stats, s.str()});
50 0 assertions.push_back({stats, s.str()});
50 0 assertions.push_back({stats, s.str()});
260 50 22 for (auto& row : assertions) {
262 50 0 auto result = stats.assertionResult;
264 50 0 bool is_test = result.getResultType() != ResultWas::Info && result.getResultType() != ResultWas::Warning;
50 0 bool is_test = result.getResultType() != ResultWas::Info && result.getResultType() != ResultWas::Warning;
50 0 bool is_test = result.getResultType() != ResultWas::Info && result.getResultType() != ResultWas::Warning;
50 0 bool is_test = result.getResultType() != ResultWas::Info && result.getResultType() != ResultWas::Warning;
267 50 0 ostream& ss = result.succeeded() ? startLine() : startErrorLine();
50 0 ostream& ss = result.succeeded() ? startLine() : startErrorLine();
50 0 ostream& ss = result.succeeded() ? startLine() : startErrorLine();
0 0 ostream& ss = result.succeeded() ? startLine() : startErrorLine();
269 50 0 if (is_test) {
271 50 0 if (result.succeeded()) {
50 0 if (result.succeeded()) {
272 50 0 ss << "ok";
275 0 0 ss << "not ok";
278 50 0 ss << " " << scope->count << " -";
50 0 ss << " " << scope->count << " -";
50 0 ss << " " << scope->count << " -";
282 50 0 Colour cg(color); (void)cg;
283 50 0 ss << row.expr;
284 50 0 ss << " # at " << result.getSourceInfo();
50 0 ss << " # at " << result.getSourceInfo();
50 0 ss << " # at " << result.getSourceInfo();
287 50 0 ss << endl;
289 50 0 if (is_test && !result.succeeded()) {
50 0 if (is_test && !result.succeeded()) {
0 50 if (is_test && !result.succeeded()) {
0 50 if (is_test && !result.succeeded()) {
290 0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
0 0 startErrorLine() << "#\e[1;31m Failed test in section [" << scope->fullname << "] at " << result.getSourceInfo() << "\e[0m" << endl;
304 0 0 if (stats.info.name.length()) ss << stats.info.name << ": ";
305 0 0 ss << speed(stats.mean.point.count()) << ", " << spent(stats.mean.point.count()) << endl;
0 0 ss << speed(stats.mean.point.count()) << ", " << spent(stats.mean.point.count()) << endl;
0 0 ss << speed(stats.mean.point.count()) << ", " << spent(stats.mean.point.count()) << endl;
0 0 ss << speed(stats.mean.point.count()) << ", " << spent(stats.mean.point.count()) << endl;
0 0 ss << speed(stats.mean.point.count()) << ", " << spent(stats.mean.point.count()) << endl;
328 0 0 if (ns < usec) { val = ns; units = "ns"; }
329 0 0 else if (ns < msec) { val = ns / usec; units = "us"; }
330 0 0 else if (ns < sec) { val = ns / static_cast(msec); units = "ms"; }
331 0 0 else if (ns < min) { val = ns / static_cast(sec); units = "s"; }
336 0 0 return string(buf, sz);
342 0 0 if (ns < usec) { val = 1000/ns; units = "M"; }
343 0 0 else if (ns < msec) { val = 1000000/ns; units = "K"; }
348 0 0 return string(buf, sz);
354 2 0 CATCH_REGISTER_REPORTER("perl", PerlReporter);
2 0 CATCH_REGISTER_REPORTER("perl", PerlReporter);
362 5 0 std::vector argv = {"test"};
364 4 5 for (int i = 3; i < items; ++i) {
366 0 4 if (!SvOK(arg)) continue;
0 0 if (!SvOK(arg)) continue;
0 0 if (!SvOK(arg)) continue;
367 4 0 argv.push_back(SvPV_nolen(arg));
0 0 argv.push_back(SvPV_nolen(arg));
4 0 argv.push_back(SvPV_nolen(arg));
370 5 0 argv.push_back("-i");
371 5 0 argv.push_back("-r");
372 5 0 argv.push_back("perl");
374 5 0 session.useConfigData({});
5 0 session.useConfigData({});
375 5 0 err = session.applyCommandLine(argv.size(), argv.data());
377 0 5 if (err) croak("session.applyCommandLine: error %d", err);
379 0 5 PerlReporter::context.count = SvUV(count);
5 0 PerlReporter::context.count = SvUV(count);
380 0 5 PerlReporter::context.failed = SvUV(failed);
5 0 PerlReporter::context.failed = SvUV(failed);
383 5 0 RETVAL = session.run() == 0;
385 5 0 sv_setuv(count, PerlReporter::context.count);
386 5 0 sv_setuv(failed, PerlReporter::context.failed);