FreeNOS
TAPReporter.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include "TAPReporter.h"
22
23TAPReporter::TAPReporter(int argc, char **argv)
24 : TestReporter(argc, argv)
25{
26 m_count = 1;
27}
28
30{
31 if (!m_multiline)
32 printf("1..%d # Start %s\r\n", tests.count(), m_argv[0]);
33
34#ifdef __HOST__
35 fflush(stdout);
36#endif /* __HOST__ */
37}
38
42
44{
45 if (!m_multiline)
46 {
47 switch (result.getResult())
48 {
49 case TestResult::Success: printf("ok %d %s\r\n", m_count, *test.getName()); break;
50 case TestResult::Failure: printf("not ok %d %s %s\r\n", m_count, *test.getName(), *result.getDescription()); break;
51 case TestResult::Skipped: printf("ok %d %s # SKIP\r\n", m_count, *test.getName()); break;
52 }
53 m_count++;
54 }
55 else
56 {
57 switch (result.getResult())
58 {
59 case TestResult::Success: printf("# Finish %s OK\r\n", *test.getName()); break;
60 case TestResult::Failure: printf("# Finish %s FAIL\r\n", *test.getName()); break;
61 case TestResult::Skipped: printf("# Finish %s SKIP\r\n", *test.getName()); break;
62 }
63 }
64
65#ifdef __HOST__
66 fflush(stdout);
67#endif /* __HOST__ */
68}
69
71{
72 if (m_multiline)
73 {
74 printf("# Completed ");
75
76 if (m_fail)
77 printf("FAIL ");
78 else
79 printf("OK ");
80
81 printf("(%d passed %d failed %d skipped %d total)\r\n",
83
84#ifdef __HOST__
85 fflush(stdout);
86#endif /* __HOST__ */
87 }
88}
Simple linked list template class.
Definition List.h:37
Size count() const
Get the number of items on the list.
Definition List.h:402
virtual void reportBegin(List< TestInstance * > &tests)
Report start of testing.
TAPReporter(int argc, char **argv)
Constructor.
virtual void reportAfter(TestInstance &test, TestResult &result)
Report finish of a test.
virtual void reportBefore(TestInstance &test)
Report start of a test.
virtual void reportFinish(List< TestInstance * > &tests)
Report completion of all tests.
uint m_count
Test counter.
Definition TAPReporter.h:68
Represents a test instance.
const String & getName() const
Retrieve test instance name.
Responsible for outputting test results.
uint m_ok
Test statistics.
char ** m_argv
Argument values.
bool m_multiline
Multi line output.
Represents a Test result created by a TestInstance.
Definition TestResult.h:48
String & getDescription()
Get result description.
const Result getResult() const
Get result code.
C int printf(const char *format,...)
Output a formatted string to standard output.
Definition printf.cpp:22