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

Unified Diff: pkg/analysis_server/test/analysis/notification_errors_test.dart

Issue 1392683003: Linter hookup into AS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master. Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/pubspec.yaml ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/analysis/notification_errors_test.dart
diff --git a/pkg/analysis_server/test/analysis/notification_errors_test.dart b/pkg/analysis_server/test/analysis/notification_errors_test.dart
index aa841e3d47fcbba7a0de86648202d989c3afc68e..e1a58637fee627f22c2c33936f391b5a230f2f1c 100644
--- a/pkg/analysis_server/test/analysis/notification_errors_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_errors_test.dart
@@ -8,6 +8,8 @@ import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/domain_analysis.dart';
import 'package:analysis_server/src/protocol.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/services/lint.dart';
+import 'package:linter/src/linter.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:unittest/unittest.dart';
@@ -23,6 +25,9 @@ main() {
class NotificationErrorsTest extends AbstractAnalysisTest {
Map<String, List<AnalysisError>> filesErrors = {};
+ /// Cached model state in case tests need to set task model to on/off.
+ bool wasTaskModelEnabled;
+
void processNotification(Notification notification) {
if (notification.event == ANALYSIS_ERRORS) {
var decoded = new AnalysisErrorsParams.fromNotification(notification);
@@ -34,6 +39,13 @@ class NotificationErrorsTest extends AbstractAnalysisTest {
void setUp() {
super.setUp();
server.handlers = [new AnalysisDomainHandler(server),];
+ wasTaskModelEnabled = AnalysisEngine.instance.useTaskModel;
+ }
+
+ @override
+ void tearDown() {
+ AnalysisEngine.instance.useTaskModel = wasTaskModelEnabled;
+ super.tearDown();
}
test_importError() {
@@ -54,6 +66,46 @@ import 'does_not_exist.dart';
});
}
+ test_lintError() {
+ // Requires task model.
+ AnalysisEngine.instance.useTaskModel = true;
+
+ var camelCaseTypesLintName = 'camel_case_types';
+
+ addFile(
+ '$projectPath/.analysis_options',
+ '''
+linter:
+ rules:
+ - $camelCaseTypesLintName
+''');
+
+ addTestFile('class a { }');
+
+ Request request =
+ new AnalysisSetAnalysisRootsParams([projectPath], []).toRequest('0');
+ handleSuccessfulRequest(request);
+
+ return waitForTasksFinished().then((_) {
+ // Confirm lint is registered.
+ expect(lintRegistry, isNotEmpty);
+ AnalysisContext testContext = server.getContainingContext(testFile);
+ List<Linter> lints = lintRegistry[testContext];
+ // Registry should only contain single lint rule.
+ expect(lints, hasLength(1));
+ LintRule lint = lints.first as LintRule;
+ expect(lint.name, camelCaseTypesLintName);
+ // Verify lint error result.
+ List<AnalysisError> errors = filesErrors[testFile];
+ expect(errors, hasLength(1));
+ AnalysisError error = errors[0];
+ expect(error.location.file, '/project/bin/test.dart');
+ expect(error.severity, AnalysisErrorSeverity.INFO);
+ expect(error.type, AnalysisErrorType.LINT);
+ expect(error.message, lint.description);
+ });
+ }
+
test_notInAnalysisRoot() {
createProject();
String otherFile = '/other.dart';
« no previous file with comments | « pkg/analysis_server/pubspec.yaml ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698