Skip to content

Commit 12710d6

Browse files
committed
Delete Exception from coverage
1 parent 3ee5e03 commit 12710d6

11 files changed

+71
-39
lines changed

.github/workflows/test-mac.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
run: |
6060
LLVM_PROFILE_FILE=./build/test-argo-debug.profraw ./build/test-argo-debug
6161
/usr/local/opt/llvm/bin/llvm-profdata merge -sparse ./build/test-argo-debug.profraw -o ./build/coverage.profdata
62-
/usr/local/opt/llvm/bin/llvm-cov show ./build/test-argo-debug -instr-profile=./build/coverage.profdata -ignore-filename-regex="tests*" > ./build/coverage.txt
62+
/usr/local/opt/llvm/bin/llvm-cov show ./build/test-argo-debug -instr-profile=./build/coverage.profdata -ignore-filename-regex="tests*" -ignore-filename-regex="Argo/ArgoExceptions.cc" > ./build/coverage.txt
6363
6464
- name: Upload coverage reports to Codecov
6565
uses: codecov/codecov-action@v3

Argo/ArgoArg.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,19 @@ consteval auto get_type_name_base_type([[maybe_unused]] size_t n = 0) {
142142
template <class T, NArgs TNArgs>
143143
consteval auto get_base_type_name_form_stl() {
144144
if constexpr (is_array_v<T>) {
145-
return []<size_t... Is>(index_sequence<Is...>) {
145+
return []<size_t... Is>(index_sequence<Is...>) consteval {
146146
return ((get_type_name_base_type<array_base_t<T>>(Is) + String(",")) +
147147
...);
148148
}(make_index_sequence<TNArgs.nargs>())
149149
.removeTrail();
150150
} else if constexpr (is_vector_v<T>) {
151-
return []<size_t... Is>(index_sequence<Is...>) {
151+
return []<size_t... Is>(index_sequence<Is...>) consteval {
152152
return ((get_type_name_base_type<vector_base_t<T>>(Is) + String(",")) +
153153
...)
154154
.removeTrail();
155155
}(make_index_sequence<TNArgs.nargs>());
156156
} else if constexpr (is_tuple_v<T>) {
157-
return []<class... U>(type_sequence<U...>) {
157+
return []<class... U>(type_sequence<U...>) consteval {
158158
return (((get_type_name_base_type<vector_base_t<U>>()) + String(",")) +
159159
...);
160160
}(make_type_sequence_t<T>())

Argo/ArgoArgName.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct ArgName {
4646
}
4747

4848
template <size_t M>
49-
[[nodiscard]] ARGO_ALWAYS_INLINE constexpr auto operator==(
49+
[[nodiscard]] ARGO_ALWAYS_INLINE consteval auto operator==(
5050
const ArgName<M>& lhs) const -> bool {
5151
return this->getKey() == lhs.getKey();
5252
}

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})
123123
${CLI11_LIBRARY})
124124
set_target_properties(${release_target_name} PROPERTIES CXX_STANDARD 23)
125125
target_compile_options(
126-
${release_target_name} PRIVATE -Wno-writable-strings -O3 -Os
126+
${release_target_name} PRIVATE -Wno-writable-strings -O3
127127
-fbracket-depth=1024)
128128
endforeach()
129129
endif()

Taskfile.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tasks:
1515
cmds:
1616
- ./build/test-argo-debug &> /dev/null
1717
- $PROF_DATA merge -sparse ./build/test-argo-debug.profraw -o ./build/coverage.profdata
18-
- $LLVM_COV report ./build/test-argo-debug -instr-profile=./build/coverage.profdata -ignore-filename-regex="tests*"
18+
- $LLVM_COV report ./build/test-argo-debug -instr-profile=./build/coverage.profdata -ignore-filename-regex="tests*" -ignore-filename-regex="Argo/ArgoExceptions.cc"
1919
env:
2020
LLVM_PROFILE_FILE: ./build/test-argo-debug.profraw
2121
PROF_DATA: /usr/local/opt/llvm/bin/llvm-profdata

benchmarks/argo.cc

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Argo;
22

3-
// #include <iostream>
43
#include <string>
54

65
using namespace Argo;

benchmarks/argparse.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) -> int {
2323
program.add_argument("-n", "--arg16").default_value(false);
2424
program.add_argument("--arg18").nargs(100).scan<'d', int>();
2525

26-
// program.parse_args(argc, argv);
27-
28-
std::cout << program << '\n';
26+
program.parse_args(argc, argv);
2927
#endif
3028
return 0;
3129
}

benchmarks/cli11.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) {
3333
std::vector<int> arg18;
3434
app.add_option("--arg18", arg18);
3535

36-
// CLI11_PARSE(app, argc, argv);
37-
std::cout << app.help() << '\n';
36+
CLI11_PARSE(app, argc, argv);
3837
#endif
3938
}

benchmarks/parser.cc

+32-3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ BENCHMARK(ArgoParser);
100100
static void CLI11Parser(benchmark::State& state) {
101101
for (auto _ : state) {
102102
auto app = CLI::App{"App description"};
103+
103104
int arg1;
104105
app.add_option("--arg1", arg1);
105106
double arg2;
@@ -174,9 +175,8 @@ BENCHMARK(CLI11Parser);
174175
#if argparse_FOUND
175176

176177
static void argparseParser(benchmark::State& state) {
178+
auto program = argparse::ArgumentParser("program_name");
177179
for (auto _ : state) {
178-
auto program = argparse::ArgumentParser("program_name");
179-
180180
program.add_argument("--arg1", "-a1").scan<'i', int>();
181181
program.add_argument("--arg2", "-a2").scan<'g', double>();
182182
program.add_argument("--arg3", "-a3");
@@ -207,8 +207,37 @@ static void argparseParser(benchmark::State& state) {
207207
program.add_argument("--arg28", "-a28");
208208
program.add_argument("--arg29", "-a29");
209209
program.add_argument("--arg30", "-a30");
210-
211210
program.parse_args(argc, argv);
211+
benchmark::DoNotOptimize(program.get<int>("--arg1"));
212+
benchmark::DoNotOptimize(program.get<double>("--arg2"));
213+
benchmark::DoNotOptimize(program.get<std::string>("--arg3"));
214+
benchmark::DoNotOptimize(program.get<std::string>("--arg4"));
215+
benchmark::DoNotOptimize(program.get<int>("--arg5"));
216+
benchmark::DoNotOptimize(program.get<double>("--arg6"));
217+
benchmark::DoNotOptimize(program.get<std::string>("--arg7"));
218+
benchmark::DoNotOptimize(program.get<std::string>("--arg8"));
219+
benchmark::DoNotOptimize(program.get<int>("--arg9"));
220+
benchmark::DoNotOptimize(program.get<int>("--arg10"));
221+
benchmark::DoNotOptimize(program.get<std::vector<std::string>>("--arg11"));
222+
benchmark::DoNotOptimize(program.get<std::vector<std::string>>("--arg12"));
223+
benchmark::DoNotOptimize(program.get<int64_t>("--arg13"));
224+
benchmark::DoNotOptimize(program.get<double>("--arg14"));
225+
benchmark::DoNotOptimize(program.get<std::string>("--arg15"));
226+
benchmark::DoNotOptimize(program.get<double>("--arg16"));
227+
benchmark::DoNotOptimize(program.get<int>("--arg17"));
228+
benchmark::DoNotOptimize(program.get<std::vector<std::string>>("--arg18"));
229+
benchmark::DoNotOptimize(program.get<std::string>("--arg19"));
230+
benchmark::DoNotOptimize(program.get<uint8_t>("--arg20"));
231+
benchmark::DoNotOptimize(program.get<double>("--arg21"));
232+
benchmark::DoNotOptimize(program.get<std::vector<std::string>>("--arg22"));
233+
benchmark::DoNotOptimize(program.get<int>("--arg23"));
234+
benchmark::DoNotOptimize(program.get<int>("--arg24"));
235+
benchmark::DoNotOptimize(program.get<std::string>("--arg25"));
236+
benchmark::DoNotOptimize(program.get<int>("--arg26"));
237+
benchmark::DoNotOptimize(program.get<std::vector<std::string>>("--arg27"));
238+
benchmark::DoNotOptimize(program.get<std::string>("--arg28"));
239+
benchmark::DoNotOptimize(program.get<std::string>("--arg29"));
240+
benchmark::DoNotOptimize(program.get<std::string>("--arg30"));
212241
}
213242
}
214243

tests/HelpGenerate.cc

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Argo;
2+
3+
#include <gmock/gmock.h>
4+
#include <gtest/gtest.h>
5+
6+
TEST(prgoTest, Help) {
7+
{
8+
auto argo = Argo::Parser<"Help 1">("program");
9+
auto parser = argo.addArg<"arg0,k", int>()
10+
.addArg<"arg1,a", int, Argo::nargs('+')>()
11+
.addArg<"arg2", int, Argo::nargs('+')>(
12+
Argo::description("This is arg2"))
13+
.addArg<"arg3", std::tuple<int, double, std::string> >(
14+
Argo::description("This is arg3\nlong description"));
15+
16+
const auto* expect_help = R"(
17+
Usage:
18+
program [options...]
19+
20+
Options:
21+
-k, --arg0 [<NUMBER>]
22+
-a, --arg1 <NUMBER,...>
23+
--arg2 <NUMBER,...> This is arg2
24+
--arg3 <NUMBER,FLOAT,STRING> This is arg3
25+
long description
26+
)";
27+
28+
EXPECT_EQ(parser.formatHelp(true), expect_help);
29+
}
30+
}

tests/parser.cc

-23
Original file line numberDiff line numberDiff line change
@@ -241,29 +241,6 @@ TEST(ArgoTest, NargException) {
241241
}
242242
}
243243

244-
TEST(ArgoTest, Help) { // TODO(gen740): more help
245-
{
246-
auto argo = Argo::Parser<"Help 1">("program");
247-
auto parser = argo //
248-
.addArg<"arg0,k", int>()
249-
.addArg<"arg1,a", int, Argo::nargs('+')>()
250-
.addArg<"arg2", int, Argo::nargs('+')>(
251-
Argo::description("This is arg2"));
252-
253-
const auto* expect_help = R"(
254-
Usage:
255-
program [options...]
256-
257-
Options:
258-
-k, --arg0 [<NUMBER>]
259-
-a, --arg1 <NUMBER,...>
260-
--arg2 <NUMBER,...> This is arg2
261-
)";
262-
263-
EXPECT_EQ(parser.formatHelp(true), expect_help);
264-
}
265-
}
266-
267244
TEST(ArgoTest, Required) {
268245
{
269246
auto [argc, argv] = createArgcArgv( //

0 commit comments

Comments
 (0)