@@ -39,12 +39,10 @@ class TestDiagnosticConsumer : public DiagnosticConsumer {
39
39
struct TestDiagnostic : public Diagnostic {
40
40
TestDiagnostic (DiagID ID, DiagGroupID GroupID) : Diagnostic(ID, GroupID) {}
41
41
};
42
- } // end anonymous namespace
43
42
44
- static void diagnosticGroupsTestCase (
45
- llvm::function_ref<void (DiagnosticEngine &)> diagnose,
46
- llvm::function_ref<void(const DiagnosticInfo &)> callback,
47
- unsigned expectedNumCallbackCalls) {
43
+ static void testCase (llvm::function_ref<void (DiagnosticEngine &)> diagnose,
44
+ llvm::function_ref<void(const DiagnosticInfo &)> callback,
45
+ unsigned expectedNumCallbackCalls) {
48
46
SourceManager sourceMgr;
49
47
DiagnosticEngine diags (sourceMgr);
50
48
@@ -63,58 +61,10 @@ static void diagnosticGroupsTestCase(
63
61
EXPECT_EQ (count, expectedNumCallbackCalls);
64
62
}
65
63
66
- TEST (DiagnosticGroups, PrintDiagnosticGroups) {
67
- // Test that we append the correct group in the format string.
68
- diagnosticGroupsTestCase (
69
- [](DiagnosticEngine &diags) {
70
- diags.setPrintDiagnosticNamesMode (PrintDiagnosticNamesMode::Group);
71
-
72
- TestDiagnostic diagnostic (diag::error_immediate_mode_missing_stdlib.ID ,
73
- DiagGroupID::DeprecatedDeclaration);
74
- diags.diagnose (SourceLoc (), diagnostic);
75
- },
76
- [](const DiagnosticInfo &info) {
77
- EXPECT_TRUE (info.FormatString .ends_with (" [DeprecatedDeclaration]" ));
78
- },
79
- /* expectedNumCallbackCalls=*/ 1 );
80
-
81
- diagnosticGroupsTestCase (
82
- [](DiagnosticEngine &diags) {
83
- diags.setPrintDiagnosticNamesMode (PrintDiagnosticNamesMode::Group);
84
-
85
- TestDiagnostic diagnostic (diag::error_immediate_mode_missing_stdlib.ID ,
86
- DiagGroupID::no_group);
87
- diags.diagnose (SourceLoc (), diagnostic);
88
- },
89
- [](const DiagnosticInfo &info) {
90
- EXPECT_FALSE (info.FormatString .ends_with (" ]" ));
91
- },
92
- /* expectedNumCallbackCalls=*/ 1 );
93
- }
94
-
95
- TEST (DiagnosticGroups, DiagnosticsWrappersInheritGroups) {
96
- // Test that we don't loose the group of a diagnostic when it gets wrapped in
97
- // another one.
98
- diagnosticGroupsTestCase (
99
- [](DiagnosticEngine &diags) {
100
- diags.setPrintDiagnosticNamesMode (PrintDiagnosticNamesMode::Group);
101
-
102
- TestDiagnostic diagnostic (diag::error_immediate_mode_missing_stdlib.ID ,
103
- DiagGroupID::DeprecatedDeclaration);
104
- diags.diagnose (SourceLoc (), diagnostic)
105
- .limitBehaviorUntilSwiftVersion (DiagnosticBehavior::Warning, 99 );
106
- },
107
- [](const DiagnosticInfo &info) {
108
- EXPECT_EQ (info.ID , diag::error_in_a_future_swift_lang_mode.ID );
109
- EXPECT_TRUE (info.FormatString .ends_with (" [DeprecatedDeclaration]" ));
110
- },
111
- /* expectedNumCallbackCalls=*/ 1 );
112
- }
113
-
114
64
TEST (DiagnosticGroups, TargetAll) {
115
65
// Test that uncategorized diagnostics are escalated when escalating all
116
66
// warnings.
117
- diagnosticGroupsTestCase (
67
+ testCase (
118
68
[](DiagnosticEngine &diags) {
119
69
const std::vector rules = {
120
70
WarningAsErrorRule (WarningAsErrorRule::Action::Enable)};
@@ -139,16 +89,16 @@ TEST(DiagnosticGroups, OverrideBehaviorLimitations) {
139
89
DiagGroupID::DeprecatedDeclaration);
140
90
141
91
// Make sure ID actually is an error by default.
142
- diagnosticGroupsTestCase (
92
+ testCase (
143
93
[&diagnostic](DiagnosticEngine &diags) {
144
94
diags.diagnose (SourceLoc (), diagnostic);
145
95
},
146
96
[](const DiagnosticInfo &info) {
147
- EXPECT_TRUE (info.Kind == DiagnosticKind::Error);
97
+ EXPECT_EQ (info.Kind , DiagnosticKind::Error);
148
98
},
149
99
/* expectedNumCallbackCalls=*/ 1 );
150
100
151
- diagnosticGroupsTestCase (
101
+ testCase (
152
102
[&diagnostic](DiagnosticEngine &diags) {
153
103
const std::vector rules = {WarningAsErrorRule (
154
104
WarningAsErrorRule::Action::Enable, " DeprecatedDeclaration" )};
@@ -172,7 +122,7 @@ TEST(DiagnosticGroups, OverrideBehaviorLimitations) {
172
122
DiagGroupID::DeprecatedDeclaration);
173
123
174
124
// Make sure ID actually is a warning by default.
175
- diagnosticGroupsTestCase (
125
+ testCase (
176
126
[&diagnostic](DiagnosticEngine &diags) {
177
127
diags.diagnose (SourceLoc (), diagnostic);
178
128
},
@@ -181,7 +131,7 @@ TEST(DiagnosticGroups, OverrideBehaviorLimitations) {
181
131
},
182
132
/* expectedNumCallbackCalls=*/ 1 );
183
133
184
- diagnosticGroupsTestCase (
134
+ testCase (
185
135
[&diagnostic](DiagnosticEngine &diags) {
186
136
const std::vector rules = {WarningAsErrorRule (
187
137
WarningAsErrorRule::Action::Enable, " DeprecatedDeclaration" )};
@@ -196,3 +146,5 @@ TEST(DiagnosticGroups, OverrideBehaviorLimitations) {
196
146
/* expectedNumCallbackCalls=*/ 1 );
197
147
}
198
148
}
149
+
150
+ } // end anonymous namespace
0 commit comments