blob: ee025d52da6bd417f42a42d81ab7934386d79bba (
plain) (
blame)
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
88
89
90
91
92
93
94
95
|
#pragma once
#include <iosfwd>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
/**
* You need to use these functions if you're customizing tests initialization
* or writing a custom `main`.
*/
namespace NGTest {
/**
* Default `main` implementation.
*/
int Main(int argc, char** argv);
/**
* CLI parsing result.
*/
struct TFlags {
/**
* Argument for `ListTests` function.
*/
int ListLevel = 0;
/**
* Where to print listed tests. Empty string means print to `stdout`.
*/
std::string ListPath = "";
/**
* Path to trace file. If empty, tracing is not enabled.
*/
std::string TracePath = "";
/**
* Should trace file be opened for append rather than just write.
*/
bool AppendTrace = false;
/**
* Test filters.
*/
std::string Filter = "*";
/**
* Number of CLI arguments for GTest init function (not counting the last null one).
*/
int GtestArgc = 0;
/**
* CLI arguments for GTest init function.
* The last one is nullptr.
*/
std::vector<char*> GtestArgv = {};
};
/**
* Parse unittest-related flags. Test binaries support flags from `library/cpp/testing/unittest` and flags from gtest.
* This means that there are usually two parsing passes. The first one parses arguments as recognized
* by the `library/cpp/testing/unittest`, so things like `--trace-path` and filters. The second one parses flags
* as recognized by gtest.
*/
TFlags ParseFlags(int argc, char** argv);
/**
* List tests using the unittest style and exit.
*
* This function should be called after initializing google tests because test parameters are instantiated
* during initialization.
*
* @param listLevel verbosity of test list. `0` means don't print anything and don't exit, `1` means print
* test suites, `2` means print individual tests.
*/
void ListTests(int listLevel, const std::string& listPath);
/**
* Remove default result reporter, the one that prints to stdout.
*/
void UnsetDefaultReporter();
/**
* Set trace reporter.
*
* Trace files are used by arcadia CI to interact with test runner. They consist of JSON objects, one per line.
* Each object represents an event, such as 'test started' or 'test finished'.
*
* @param traceFile where to write trace file. This stream should exist for the entire duration of test run.
*/
void SetTraceReporter(std::ostream* traceFile);
}
|