LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
TestRunIndex.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "TestOutline.hpp"
4
5#include <cstddef>
6#include <cstdint>
7#include <filesystem>
8#include <functional>
9#include <string>
10#include <string_view>
11#include <unordered_map>
12#include <vector>
13
14namespace analyzer
15{
16
18inline constexpr std::string_view kMergedLogSuffix = "__merged_logs.txt";
19
21enum class FailureSource
22{
23 None,
24 StepFail,
26};
27
30{
31 std::filesystem::path file;
32 std::string testName;
34 std::string timestamp;
35 std::int64_t durationUs {-1};
36 std::int64_t entries {-1};
37 std::string failureMessage;
39};
40
43[[nodiscard]] TestRunEntry ReadTestLogSummary(const std::filesystem::path& file);
44
49[[nodiscard]] std::string FindDecisiveFailureMessage(const std::filesystem::path& file);
50
55[[nodiscard]] std::unordered_map<std::string, std::string>
56ReadRobotFailures(const std::filesystem::path& folder);
57
61[[nodiscard]] std::string TestNameKey(std::string_view name);
62
64[[nodiscard]] std::string CollapseWhitespace(std::string_view text);
65
69[[nodiscard]] std::string NormalizeFailureMessage(std::string_view message);
70
72using ScanProgress = std::function<bool(std::size_t done, std::size_t total)>;
73
83[[nodiscard]] std::vector<TestRunEntry> ScanResultsFolder(const std::filesystem::path& folder,
84 const ScanProgress& progress = {});
85
88{
89 std::string message;
90 std::vector<std::size_t> members;
91};
92
95[[nodiscard]] std::vector<FailureGroup> GroupFailures(const std::vector<TestRunEntry>& entries);
96
97} // namespace analyzer
Definition ActorDiscoverer.cpp:13
constexpr std::string_view kMergedLogSuffix
File-name suffix of a safeAPI merged test log inside a results folder.
Definition TestRunIndex.hpp:18
std::vector< TestRunEntry > ScanResultsFolder(const fs::path &folder, const ScanProgress &progress)
Definition TestRunIndex.cpp:342
std::unordered_map< std::string, std::string > ReadRobotFailures(const fs::path &folder)
Definition TestRunIndex.cpp:287
std::string TestNameKey(std::string_view name)
Definition TestRunIndex.cpp:298
TestRunEntry ReadTestLogSummary(const fs::path &file)
Definition TestRunIndex.cpp:203
std::function< bool(std::size_t done, std::size_t total)> ScanProgress
Called after each scanned log with (done, total); return false to cancel.
Definition TestRunIndex.hpp:72
FailureSource
Where TestRunEntry::failureMessage came from.
Definition TestRunIndex.hpp:22
@ RobotXml
xunit.xml <failure message> or output.xml test status text
@ None
no message found (or the test did not fail)
@ StepFail
the decisive STEP_FAIL of the log (see BuildTestOutline)
std::vector< FailureGroup > GroupFailures(const std::vector< TestRunEntry > &entries)
Definition TestRunIndex.cpp:393
std::string FindDecisiveFailureMessage(const fs::path &file)
Definition TestRunIndex.cpp:248
std::string NormalizeFailureMessage(std::string_view message)
Definition TestRunIndex.cpp:326
TestVerdict
Definition TestOutline.hpp:57
std::string CollapseWhitespace(std::string_view text)
Collapses whitespace runs (including newlines) to one space and trims.
Definition TestRunIndex.cpp:307
Failing tests sharing one normalised message.
Definition TestRunIndex.hpp:88
std::vector< std::size_t > members
indices into the entries, in entry order
Definition TestRunIndex.hpp:90
std::string message
message of the first member
Definition TestRunIndex.hpp:89
One test of a results folder, read without loading the whole log.
Definition TestRunIndex.hpp:30
FailureSource failureSource
Definition TestRunIndex.hpp:38
std::string failureMessage
FAIL only, on one line (whitespace collapsed)
Definition TestRunIndex.hpp:37
TestVerdict verdict
header Status
Definition TestRunIndex.hpp:33
std::int64_t durationUs
last − first event timestamp; -1 = unknown
Definition TestRunIndex.hpp:35
std::int64_t entries
header Entries; -1 = absent
Definition TestRunIndex.hpp:36
std::filesystem::path file
Definition TestRunIndex.hpp:31
std::string timestamp
header Timestamp, else the first event's timestamp
Definition TestRunIndex.hpp:34
std::string testName
header Test Case, else the file name without the suffix
Definition TestRunIndex.hpp:32