Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: pkg/analysis_server/test/analysis/notification_errors_test.dart

Issue 2545553007: Add support for generating lints when using the new driver (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.analysis.notification_errors; 5 library test.analysis.notification_errors;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/constants.dart'; 8 import 'package:analysis_server/src/constants.dart';
9 import 'package:analysis_server/src/context_manager.dart';
9 import 'package:analysis_server/src/domain_analysis.dart'; 10 import 'package:analysis_server/src/domain_analysis.dart';
11 import 'package:analyzer/src/dart/analysis/driver.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/services/lint.dart'; 13 import 'package:analyzer/src/services/lint.dart';
12 import 'package:linter/src/linter.dart'; 14 import 'package:linter/src/linter.dart';
13 import 'package:test/test.dart'; 15 import 'package:test/test.dart';
14 import 'package:test_reflective_loader/test_reflective_loader.dart'; 16 import 'package:test_reflective_loader/test_reflective_loader.dart';
15 17
16 import '../analysis_abstract.dart'; 18 import '../analysis_abstract.dart';
17 19
18 main() { 20 main() {
19 defineReflectiveSuite(() { 21 defineReflectiveSuite(() {
20 defineReflectiveTests(NotificationErrorsTest); 22 defineReflectiveTests(NotificationErrorsTest);
23 defineReflectiveTests(NotificationErrorsTest_Driver);
21 }); 24 });
22 } 25 }
23 26
24 @reflectiveTest 27 @reflectiveTest
25 class NotificationErrorsTest extends AbstractAnalysisTest { 28 class AbstractNotificationErrorsTest extends AbstractAnalysisTest {
26 Map<String, List<AnalysisError>> filesErrors = {}; 29 Map<String, List<AnalysisError>> filesErrors = {};
27 30
28 void processNotification(Notification notification) { 31 void processNotification(Notification notification) {
29 if (notification.event == ANALYSIS_ERRORS) { 32 if (notification.event == ANALYSIS_ERRORS) {
30 var decoded = new AnalysisErrorsParams.fromNotification(notification); 33 var decoded = new AnalysisErrorsParams.fromNotification(notification);
31 filesErrors[decoded.file] = decoded.errors; 34 filesErrors[decoded.file] = decoded.errors;
32 } 35 }
33 } 36 }
34 37
35 @override 38 @override
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 - $camelCaseTypesLintName 71 - $camelCaseTypesLintName
69 '''); 72 ''');
70 73
71 addTestFile('class a { }'); 74 addTestFile('class a { }');
72 75
73 Request request = 76 Request request =
74 new AnalysisSetAnalysisRootsParams([projectPath], []).toRequest('0'); 77 new AnalysisSetAnalysisRootsParams([projectPath], []).toRequest('0');
75 handleSuccessfulRequest(request); 78 handleSuccessfulRequest(request);
76 79
77 await waitForTasksFinished(); 80 await waitForTasksFinished();
78 AnalysisContext testContext = server.getContainingContext(testFile); 81 List<Linter> lints;
79 List<Linter> lints = getLints(testContext); 82 if (enableNewAnalysisDriver) {
83 AnalysisDriver testDriver = (server.contextManager as ContextManagerImpl)
84 .getContextInfoFor(resourceProvider.getFolder(projectPath))
85 .analysisDriver;
86 lints = testDriver.analysisOptions.lintRules;
87 } else {
88 AnalysisContext testContext = server.getContainingContext(testFile);
89 lints = getLints(testContext);
90 }
80 // Registry should only contain single lint rule. 91 // Registry should only contain single lint rule.
81 expect(lints, hasLength(1)); 92 expect(lints, hasLength(1));
82 LintRule lint = lints.first as LintRule; 93 LintRule lint = lints.first as LintRule;
83 expect(lint.name, camelCaseTypesLintName); 94 expect(lint.name, camelCaseTypesLintName);
84 // Verify lint error result. 95 // Verify lint error result.
85 List<AnalysisError> errors = filesErrors[testFile]; 96 List<AnalysisError> errors = filesErrors[testFile];
86 expect(errors, hasLength(1)); 97 expect(errors, hasLength(1));
87 AnalysisError error = errors[0]; 98 AnalysisError error = errors[0];
88 expect(error.location.file, '/project/bin/test.dart'); 99 expect(error.location.file, '/project/bin/test.dart');
89 expect(error.severity, AnalysisErrorSeverity.INFO); 100 expect(error.severity, AnalysisErrorSeverity.INFO);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 139 }
129 '''); 140 ''');
130 await waitForTasksFinished(); 141 await waitForTasksFinished();
131 List<AnalysisError> errors = filesErrors[testFile]; 142 List<AnalysisError> errors = filesErrors[testFile];
132 expect(errors, hasLength(1)); 143 expect(errors, hasLength(1));
133 AnalysisError error = errors[0]; 144 AnalysisError error = errors[0];
134 expect(error.severity, AnalysisErrorSeverity.WARNING); 145 expect(error.severity, AnalysisErrorSeverity.WARNING);
135 expect(error.type, AnalysisErrorType.STATIC_WARNING); 146 expect(error.type, AnalysisErrorType.STATIC_WARNING);
136 } 147 }
137 } 148 }
149
150 @reflectiveTest
151 class NotificationErrorsTest extends AbstractNotificationErrorsTest {}
152
153 @reflectiveTest
154 class NotificationErrorsTest_Driver extends AbstractNotificationErrorsTest {
155 @override
156 void setUp() {
157 enableNewAnalysisDriver = true;
158 generateSummaryFiles = true;
159 super.setUp();
160 }
161
162 @failingTest
163 @override
164 test_importError() {
165 // The overridden test is failing because we're not getting any error
166 // notifications.
scheglov 2016/12/02 22:36:58 We might get error notifications, just too late fo
Brian Wilkerson 2016/12/02 22:51:30 Is there a way to wait until all communications fr
scheglov 2016/12/02 22:52:31 I don't know it.
167 return super.test_importError();
168 }
169
170 @failingTest
171 @override
172 test_ParserError() {
173 // The overridden test is failing because we're not getting any error
174 // notifications.
175 return super.test_ParserError();
176 }
177
178 @failingTest
179 @override
180 test_StaticWarning() {
181 // The overridden test is failing because we're not getting any error
182 // notifications.
183 return super.test_StaticWarning();
184 }
185 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698