/
catch_reporter_cumulative_base.hpp
87 lines (64 loc) · 3.22 KB
/
catch_reporter_cumulative_base.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED
#define CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <catch2/internal/catch_unique_ptr.hpp>
#include <iosfwd>
#include <string>
#include <vector>
namespace Catch {
struct CumulativeReporterBase : IStreamingReporter {
template<typename T, typename ChildNodeT>
struct Node {
explicit Node( T const& _value ) : value( _value ) {}
using ChildNodes = std::vector<Detail::unique_ptr<ChildNodeT>>;
T value;
ChildNodes children;
};
struct SectionNode {
explicit SectionNode(SectionStats const& _stats) : stats(_stats) {}
bool operator == (SectionNode const& other) const {
return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
}
SectionStats stats;
std::vector<Detail::unique_ptr<SectionNode>> childSections;
std::vector<AssertionStats> assertions;
std::string stdOut;
std::string stdErr;
};
using TestCaseNode = Node<TestCaseStats, SectionNode>;
using TestGroupNode = Node<TestGroupStats, TestCaseNode>;
using TestRunNode = Node<TestRunStats, TestGroupNode>;
CumulativeReporterBase( ReporterConfig const& _config ):
IStreamingReporter( _config.fullConfig() ),
stream( _config.stream() ) {}
~CumulativeReporterBase() override;
void testRunStarting( TestRunInfo const& ) override {}
void testGroupStarting( GroupInfo const& ) override {}
void testCaseStarting( TestCaseInfo const& ) override {}
void sectionStarting( SectionInfo const& sectionInfo ) override;
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& assertionStats ) override;
void sectionEnded( SectionStats const& sectionStats ) override;
void testCaseEnded( TestCaseStats const& testCaseStats ) override;
void testGroupEnded( TestGroupStats const& testGroupStats ) override;
void testRunEnded( TestRunStats const& testRunStats ) override;
//! Customization point: called after last test finishes (testRunEnded has been handled)
virtual void testRunEndedCumulative() = 0;
void skipTest(TestCaseInfo const&) override {}
std::ostream& stream;
// Note: We rely on pointer identity being stable, which is why
// which is why we store around pointers rather than values.
std::vector<Detail::unique_ptr<TestCaseNode>> m_testCases;
std::vector<Detail::unique_ptr<TestGroupNode>> m_testGroups;
std::vector<TestRunNode> m_testRuns;
Detail::unique_ptr<SectionNode> m_rootSection;
SectionNode* m_deepestSection = nullptr;
std::vector<SectionNode*> m_sectionStack;
};
} // end namespace Catch
#endif // CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED