Skip to content

Commit 843f5a2

Browse files
committed
feat: --report switch
1 parent 9a64659 commit 843f5a2

File tree

8 files changed

+55
-28
lines changed

8 files changed

+55
-28
lines changed

include/mrdox/Support/Error.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ extern MRDOX_DECL Results results;
739739
that errors will still count as errors even if
740740
they are not displayed.
741741
*/
742-
MRDOX_DECL void setMinimumLevel(unsigned level);
742+
MRDOX_DECL void setMinimumLevel(unsigned level) noexcept;
743743

744744
/** Report a message to the console.
745745

lib/Support/Error.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ static unsigned reportLevel_ = 0;
144144

145145
constinit Results results{};
146146

147+
void setMinimumLevel(unsigned level) noexcept
148+
{
149+
if( level > 4)
150+
level = 4;
151+
reportLevel_ = level;
152+
}
153+
147154
void
148155
print_impl(
149156
unsigned level,

lib/Tool/ToolArgs.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,23 @@ R"(
5050
llvm::cl::desc("The path to the addons directory."),
5151
llvm::cl::cat(commonCat))
5252

53+
, reportLevel(
54+
"report",
55+
llvm::cl::desc("The minimum reporting level (0 to 4)."),
56+
llvm::cl::cat(commonCat))
57+
58+
//
59+
// Tool options
60+
//
61+
5362
, configPath(
5463
"config",
55-
llvm::cl::desc(R"(The config filename relative to the repository root.)"),
56-
llvm::cl::cat(commonCat))
64+
llvm::cl::desc(R"(The config filename relative to the repository root.)"))
5765

5866
, outputPath(
5967
"output",
6068
llvm::cl::desc("Directory or file for generating output."),
61-
llvm::cl::init("."),
62-
llvm::cl::cat(commonCat))
63-
64-
, inputPaths(
65-
"inputs",
66-
llvm::cl::Sink,
67-
llvm::cl::desc("The path to the compilation database."),
68-
llvm::cl::cat(commonCat))
69+
llvm::cl::init("."))
6970

7071
, formatType(
7172
"format",
@@ -76,6 +77,11 @@ R"(
7677
"ignore-map-errors",
7778
llvm::cl::desc("Continue if files are not mapped correctly."),
7879
llvm::cl::init(true))
80+
81+
, inputPaths(
82+
"inputs",
83+
llvm::cl::Sink,
84+
llvm::cl::desc("The path to the compilation database."))
7985
{
8086
}
8187

lib/Tool/ToolArgs.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ class ToolArgs
3232
llvm::cl::extrahelp extraHelp;
3333

3434
llvm::cl::opt<std::string> addonsDir;
35+
llvm::cl::opt<unsigned> reportLevel;
36+
3537
llvm::cl::opt<std::string> configPath;
3638
llvm::cl::opt<std::string> outputPath;
37-
llvm::cl::list<std::string> inputPaths;
3839
llvm::cl::opt<std::string> formatType;
3940
llvm::cl::opt<bool> ignoreMappingFailures;
41+
llvm::cl::list<std::string> inputPaths;
4042

4143
// Hide all options which don't belong to us
4244
void hideForeignOptions();

test/TestArgs.cpp

+19-14
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,30 @@ R"(
4848
// Common options
4949
//
5050

51-
, action(
52-
"action",
53-
llvm::cl::desc(R"(Which action should be performed:)"),
54-
llvm::cl::init(test),
55-
llvm::cl::values(
56-
clEnumVal(test, "Compare output against expected."),
57-
clEnumVal(create, "Create missing expected xml files."),
58-
clEnumVal(update, "Update all expected xml files.")),
59-
llvm::cl::cat(commonCat))
60-
6151
, addonsDir(
6252
"addons",
6353
llvm::cl::desc("The path to the addons directory."),
6454
llvm::cl::cat(commonCat))
6555

66-
, inputPaths(
67-
"inputs",
68-
llvm::cl::Sink,
69-
llvm::cl::desc("A list of directories and/or .cpp files to test."),
56+
, reportLevel(
57+
"report",
58+
llvm::cl::desc("The minimum reporting level (0 to 4)."),
7059
llvm::cl::cat(commonCat))
7160

7261
//
7362
// Test options
7463
//
7564

65+
, action(
66+
"action",
67+
llvm::cl::desc(R"(Which action should be performed:)"),
68+
llvm::cl::init(test),
69+
llvm::cl::values(
70+
clEnumVal(test, "Compare output against expected."),
71+
clEnumVal(create, "Create missing expected xml files."),
72+
clEnumVal(update, "Update all expected xml files.")),
73+
llvm::cl::cat(commonCat))
74+
7675
, badOption(
7776
"bad",
7877
llvm::cl::desc("Write a .bad.xml file for each test failure."),
@@ -82,6 +81,12 @@ R"(
8281
"unit",
8382
llvm::cl::desc("Run all or selected unit test suites."),
8483
llvm::cl::init(true))
84+
85+
, inputPaths(
86+
"inputs",
87+
llvm::cl::Sink,
88+
llvm::cl::desc("A list of directories and/or .cpp files to test."),
89+
llvm::cl::cat(commonCat))
8590
{
8691
}
8792

test/TestArgs.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ class TestArgs
3939
llvm::cl::extrahelp extraHelp;
4040

4141
// Common options
42-
llvm::cl::opt<Action> action;
4342
llvm::cl::opt<std::string> addonsDir;
44-
llvm::cl::list<std::string> inputPaths;
43+
llvm::cl::opt<unsigned> reportLevel;
4544

4645
// Test options
46+
llvm::cl::opt<Action> action;
4747
llvm::cl::opt<bool> badOption;
4848
llvm::cl::opt<bool> unitOption;
49+
llvm::cl::list<std::string> inputPaths;
4950

5051
// Hide all options which don't belong to us
5152
void hideForeignOptions();

test/TestMain.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ int test_main(int argc, char const* const* argv)
8181
argc, argv, testArgs.usageText))
8282
return EXIT_FAILURE;
8383

84+
// Apply reportLevel
85+
report::setMinimumLevel(testArgs.reportLevel.getValue());
86+
8487
if(! testArgs.inputPaths.empty())
8588
DoTestAction();
8689

tool/ToolMain.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ int mrdox_main(int argc, char const** argv)
5555
argc, argv, toolArgs.usageText))
5656
return EXIT_FAILURE;
5757

58+
// Apply reportLevel
59+
report::setMinimumLevel(toolArgs.reportLevel.getValue());
60+
5861
if(! setupAddonsDir(toolArgs.addonsDir, argv[0],
5962
reinterpret_cast<void*>(&main)))
6063
return EXIT_FAILURE;

0 commit comments

Comments
 (0)