Skip to content

Commit f5e0631

Browse files
authored
feat: replace string-replace based tag parsing with official cucumber tag parsing (#226)
ci: update sonarqube-scan-action to v6.0.0 (#226)
1 parent 1331877 commit f5e0631

File tree

23 files changed

+1112
-193
lines changed

23 files changed

+1112
-193
lines changed

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: |
6161
cp .build/Coverage/compile_commands.json compile_commands.json
6262
63-
- uses: sonarsource/sonarqube-scan-action@1a6d90ebcb0e6a6b1d87e37ba693fe453195ae25 # v5.3.1
63+
- uses: sonarsource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6.0.0
6464
env:
6565
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6666

CMakePresets.json

Lines changed: 135 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,138 @@
11
{
2-
"version": 6,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 24,
6-
"patch": 0
7-
},
8-
"configurePresets": [
9-
{
10-
"name": "defaults",
11-
"hidden": true,
12-
"binaryDir": "${sourceDir}/.build/${presetName}",
13-
"installDir": "${sourceDir}/.install/${presetName}",
14-
"cacheVariables": {
15-
"CMAKE_EXPORT_COMPILE_COMMANDS": "On",
16-
"CMAKE_CONFIGURATION_TYPES": "Debug;Release"
17-
}
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 24,
6+
"patch": 0
187
},
19-
{
20-
"name": "Coverage",
21-
"inherits": "defaults",
22-
"generator": "Ninja",
23-
"cacheVariables": {
24-
"CMAKE_BUILD_TYPE": "Debug",
25-
"CCR_ENABLE_COVERAGE": "On"
26-
}
27-
},
28-
{
29-
"name": "Host",
30-
"inherits": "defaults",
31-
"generator": "Ninja Multi-Config"
32-
},
33-
{
34-
"name": "host-single-Debug",
35-
"displayName": "Configuration for Host Tooling and Tests, Single Config Generator, Debug",
36-
"inherits": "defaults",
37-
"cacheVariables": {
38-
"CMAKE_BUILD_TYPE": "Debug"
39-
}
40-
},
41-
{
42-
"name": "Host-Iwyu",
43-
"inherits": "defaults",
44-
"cacheVariables": {
45-
"CMAKE_CXX_INCLUDE_WHAT_YOU_USE": "include-what-you-use;-Wno-unknown-warning-option;-Xiwyu;--no_comments;-Xiwyu;--cxx17ns;-Xiwyu;--no_fwd_decls"
46-
},
47-
"generator": "Ninja Multi-Config"
48-
},
49-
{
50-
"name": "Windows",
51-
"inherits": "defaults",
52-
"toolchainFile": "${sourceDir}/cmake/toolchain-clang-x86_64-pc-windows-msvc.cmake",
53-
"environment": {
54-
"CCACHE_DEPEND": "true",
55-
"CCACHE_COMPILERTYPE": "clang-cl"
56-
},
57-
"generator": "Ninja Multi-Config"
58-
}
59-
],
60-
"buildPresets": [
61-
{
62-
"name": "Coverage",
63-
"configurePreset": "Coverage"
64-
},
65-
{
66-
"name": "Host-Release",
67-
"configuration": "Release",
68-
"configurePreset": "Host"
69-
},
70-
{
71-
"name": "Host-Debug",
72-
"configuration": "Debug",
73-
"configurePreset": "Host"
74-
},
75-
{
76-
"name": "Host-Iwyu-Debug",
77-
"configuration": "Debug",
78-
"configurePreset": "Host-Iwyu"
79-
},
80-
{
81-
"name": "host-single-Debug",
82-
"configuration": "Debug",
83-
"configurePreset": "host-single-Debug"
84-
},
85-
{
86-
"name": "Windows-Release",
87-
"configuration": "Release",
88-
"configurePreset": "Windows"
89-
},
90-
{
91-
"name": "Windows-RelWithDebInfo",
92-
"configuration": "RelWithDebInfo",
93-
"configurePreset": "Windows"
94-
}
95-
],
96-
"testPresets": [
97-
{
98-
"name": "defaults",
99-
"hidden": true,
100-
"output": {
101-
"outputOnFailure": true
102-
},
103-
"execution": {
104-
"noTestsAction": "error",
105-
"stopOnFailure": true
106-
}
107-
},
108-
{
109-
"name": "Coverage",
110-
"configurePreset": "Coverage",
111-
"configuration": "Debug",
112-
"inherits": "defaults"
113-
},
114-
{
115-
"name": "Host-Debug",
116-
"configurePreset": "Host",
117-
"configuration": "Debug",
118-
"inherits": "defaults"
119-
},
120-
{
121-
"name": "Host-Release",
122-
"configurePreset": "Host",
123-
"configuration": "Release",
124-
"inherits": "defaults"
125-
},
126-
{
127-
"name": "host-single-Debug",
128-
"configurePreset": "host-single-Debug",
129-
"configuration": "Debug",
130-
"inherits": "defaults"
131-
}
132-
]
8+
"configurePresets": [
9+
{
10+
"name": "defaults",
11+
"hidden": true,
12+
"binaryDir": "${sourceDir}/.build/${presetName}",
13+
"installDir": "${sourceDir}/.install/${presetName}",
14+
"cacheVariables": {
15+
"CMAKE_EXPORT_COMPILE_COMMANDS": "On",
16+
"CMAKE_CONFIGURATION_TYPES": "Debug;RelWithDebInfo;Release"
17+
}
18+
},
19+
{
20+
"name": "Coverage",
21+
"inherits": "defaults",
22+
"generator": "Ninja",
23+
"cacheVariables": {
24+
"CMAKE_BUILD_TYPE": "Debug",
25+
"CCR_ENABLE_COVERAGE": "On"
26+
}
27+
},
28+
{
29+
"name": "Host",
30+
"inherits": "defaults",
31+
"generator": "Ninja Multi-Config"
32+
},
33+
{
34+
"name": "host-single-Debug",
35+
"displayName": "Configuration for Host Tooling and Tests, Single Config Generator, Debug",
36+
"inherits": "defaults",
37+
"cacheVariables": {
38+
"CMAKE_BUILD_TYPE": "Debug"
39+
}
40+
},
41+
{
42+
"name": "Host-Iwyu",
43+
"inherits": "defaults",
44+
"cacheVariables": {
45+
"CMAKE_CXX_INCLUDE_WHAT_YOU_USE": "include-what-you-use;-Wno-unknown-warning-option;-Xiwyu;--no_comments;-Xiwyu;--cxx17ns;-Xiwyu;--no_fwd_decls"
46+
},
47+
"generator": "Ninja Multi-Config"
48+
},
49+
{
50+
"name": "Windows",
51+
"inherits": "defaults",
52+
"toolchainFile": "${sourceDir}/cmake/toolchain-clang-x86_64-pc-windows-msvc.cmake",
53+
"environment": {
54+
"CCACHE_DEPEND": "true",
55+
"CCACHE_COMPILERTYPE": "clang-cl"
56+
},
57+
"generator": "Ninja Multi-Config"
58+
}
59+
],
60+
"buildPresets": [
61+
{
62+
"name": "Coverage",
63+
"configurePreset": "Coverage"
64+
},
65+
{
66+
"name": "Host-Release",
67+
"configuration": "Release",
68+
"configurePreset": "Host"
69+
},
70+
{
71+
"name": "Host-Debug",
72+
"configuration": "Debug",
73+
"configurePreset": "Host"
74+
},
75+
{
76+
"name": "Host-Iwyu-Debug",
77+
"configuration": "Debug",
78+
"configurePreset": "Host-Iwyu"
79+
},
80+
{
81+
"name": "host-single-Debug",
82+
"configuration": "Debug",
83+
"configurePreset": "host-single-Debug"
84+
},
85+
{
86+
"name": "Windows-Release",
87+
"configuration": "Release",
88+
"configurePreset": "Windows"
89+
},
90+
{
91+
"name": "Windows-RelWithDebInfo",
92+
"configuration": "RelWithDebInfo",
93+
"configurePreset": "Windows"
94+
},
95+
{
96+
"name": "Windows-Debug",
97+
"configuration": "Debug",
98+
"configurePreset": "Windows"
99+
}
100+
],
101+
"testPresets": [
102+
{
103+
"name": "defaults",
104+
"hidden": true,
105+
"output": {
106+
"outputOnFailure": true
107+
},
108+
"execution": {
109+
"noTestsAction": "error",
110+
"stopOnFailure": true
111+
}
112+
},
113+
{
114+
"name": "Coverage",
115+
"configurePreset": "Coverage",
116+
"configuration": "Debug",
117+
"inherits": "defaults"
118+
},
119+
{
120+
"name": "Host-Debug",
121+
"configurePreset": "Host",
122+
"configuration": "Debug",
123+
"inherits": "defaults"
124+
},
125+
{
126+
"name": "Host-Release",
127+
"configurePreset": "Host",
128+
"configuration": "Release",
129+
"inherits": "defaults"
130+
},
131+
{
132+
"name": "host-single-Debug",
133+
"configurePreset": "host-single-Debug",
134+
"configuration": "Debug",
135+
"inherits": "defaults"
136+
}
137+
]
133138
}

cucumber_cpp/library/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ target_link_libraries(cucumber_cpp.library PUBLIC
3434
cucumber_gherkin_lib
3535
cucumber_cpp.library.report
3636
cucumber_cpp.library.engine
37+
cucumber_cpp.library.tag_expression
3738
cucumber_cpp.library.util
3839
CLI11
3940
)
@@ -47,6 +48,7 @@ target_compile_options(cucumber_cpp.library
4748
)
4849

4950
add_subdirectory(cucumber_expression)
51+
add_subdirectory(tag_expression)
5052
add_subdirectory(engine)
5153
add_subdirectory(report)
5254
add_subdirectory(util)

cucumber_cpp/library/HookRegistry.cpp

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,26 @@ namespace cucumber_cpp::library
2323
return entry.type == hookType;
2424
};
2525
};
26+
27+
auto Matches(const std::set<std::string, std::less<>>& tags)
28+
{
29+
return [&tags](const HookRegistryBase::Entry& entry)
30+
{
31+
return entry.tagExpression->Evaluate(tags);
32+
};
33+
}
2634
}
2735

2836
HookBase::HookBase(Context& context)
2937
: context{ context }
3038
{}
3139

32-
TagExpressionMatch::TagExpressionMatch(const std::string& tagExpression, const std::set<std::string, std::less<>>& tags)
33-
: matched{ IsTagExprSelected(tagExpression, tags) }
34-
{}
35-
36-
bool TagExpressionMatch::Matched() const
37-
{
38-
return matched;
39-
}
40-
41-
HookTagExpression::HookTagExpression(std::string tagExpression)
42-
: tagExpression{ std::move(tagExpression) }
43-
{}
44-
45-
std::unique_ptr<TagExpressionMatch> HookTagExpression::Match(const std::set<std::string, std::less<>>& tags) const
46-
{
47-
return std::make_unique<TagExpressionMatch>(tagExpression, tags);
48-
}
49-
50-
std::string HookTagExpression::TagExpression() const
51-
{
52-
return tagExpression;
53-
}
54-
5540
std::vector<HookMatch> HookRegistryBase::Query(HookType hookType, const std::set<std::string, std::less<>>& tags) const
5641
{
5742
std::vector<HookMatch> matches;
5843

59-
for (const Entry& entry : registry | std::views::filter(TypeFilter(hookType)))
60-
if (auto match = entry.hookTagExpression.Match(tags); match->Matched())
61-
matches.emplace_back(std::move(match), entry.factory, entry.hookTagExpression);
44+
for (const Entry& entry : registry | std::views::filter(TypeFilter(hookType)) | std::views::filter(Matches(tags)))
45+
matches.emplace_back(entry.factory);
6246

6347
return matches;
6448
}

0 commit comments

Comments
 (0)