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

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

Issue 1490233007: Remove the old task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@analyzer-breaking-0.27
Patch Set: Created 5 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/domain_analysis.dart'; 9 import 'package:analysis_server/src/domain_analysis.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/services/lint.dart'; 11 import 'package:analyzer/src/services/lint.dart';
12 import 'package:linter/src/linter.dart'; 12 import 'package:linter/src/linter.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; 13 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
15 15
16 import '../analysis_abstract.dart'; 16 import '../analysis_abstract.dart';
17 import '../utils.dart'; 17 import '../utils.dart';
18 18
19 main() { 19 main() {
20 initializeTestEnvironment(); 20 initializeTestEnvironment();
21 defineReflectiveTests(NotificationErrorsTest); 21 defineReflectiveTests(NotificationErrorsTest);
22 } 22 }
23 23
24 @reflectiveTest 24 @reflectiveTest
25 class NotificationErrorsTest extends AbstractAnalysisTest { 25 class NotificationErrorsTest extends AbstractAnalysisTest {
26 Map<String, List<AnalysisError>> filesErrors = {}; 26 Map<String, List<AnalysisError>> filesErrors = {};
27 27
28 /// Cached model state in case tests need to set task model to on/off.
29 bool wasTaskModelEnabled;
30
31 void processNotification(Notification notification) { 28 void processNotification(Notification notification) {
32 if (notification.event == ANALYSIS_ERRORS) { 29 if (notification.event == ANALYSIS_ERRORS) {
33 var decoded = new AnalysisErrorsParams.fromNotification(notification); 30 var decoded = new AnalysisErrorsParams.fromNotification(notification);
34 filesErrors[decoded.file] = decoded.errors; 31 filesErrors[decoded.file] = decoded.errors;
35 } 32 }
36 } 33 }
37 34
38 @override 35 @override
39 void setUp() { 36 void setUp() {
40 super.setUp(); 37 super.setUp();
41 server.handlers = [new AnalysisDomainHandler(server),]; 38 server.handlers = [new AnalysisDomainHandler(server),];
42 wasTaskModelEnabled = AnalysisEngine.instance.useTaskModel;
43 }
44
45 @override
46 void tearDown() {
47 AnalysisEngine.instance.useTaskModel = wasTaskModelEnabled;
48 super.tearDown();
49 } 39 }
50 40
51 test_importError() async { 41 test_importError() async {
52 createProject(); 42 createProject();
53 43
54 addTestFile(''' 44 addTestFile('''
55 import 'does_not_exist.dart'; 45 import 'does_not_exist.dart';
56 '''); 46 ''');
57 await waitForTasksFinished(); 47 await waitForTasksFinished();
58 List<AnalysisError> errors = filesErrors[testFile]; 48 List<AnalysisError> errors = filesErrors[testFile];
59 // Verify that we are generating only 1 error for the bad URI. 49 // Verify that we are generating only 1 error for the bad URI.
60 // https://github.com/dart-lang/sdk/issues/23754 50 // https://github.com/dart-lang/sdk/issues/23754
61 expect(errors, hasLength(1)); 51 expect(errors, hasLength(1));
62 AnalysisError error = errors[0]; 52 AnalysisError error = errors[0];
63 expect(error.severity, AnalysisErrorSeverity.ERROR); 53 expect(error.severity, AnalysisErrorSeverity.ERROR);
64 expect(error.type, AnalysisErrorType.COMPILE_TIME_ERROR); 54 expect(error.type, AnalysisErrorType.COMPILE_TIME_ERROR);
65 expect(error.message, startsWith('Target of URI does not exist')); 55 expect(error.message, startsWith('Target of URI does not exist'));
66 } 56 }
67 57
68 test_lintError() async { 58 test_lintError() async {
69 // Requires task model.
70 AnalysisEngine.instance.useTaskModel = true;
71
72 var camelCaseTypesLintName = 'camel_case_types'; 59 var camelCaseTypesLintName = 'camel_case_types';
73 60
74 addFile( 61 addFile(
75 '$projectPath/.analysis_options', 62 '$projectPath/.analysis_options',
76 ''' 63 '''
77 linter: 64 linter:
78 rules: 65 rules:
79 - $camelCaseTypesLintName 66 - $camelCaseTypesLintName
80 '''); 67 ''');
81 68
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 126 }
140 '''); 127 ''');
141 await waitForTasksFinished(); 128 await waitForTasksFinished();
142 List<AnalysisError> errors = filesErrors[testFile]; 129 List<AnalysisError> errors = filesErrors[testFile];
143 expect(errors, hasLength(1)); 130 expect(errors, hasLength(1));
144 AnalysisError error = errors[0]; 131 AnalysisError error = errors[0];
145 expect(error.severity, AnalysisErrorSeverity.WARNING); 132 expect(error.severity, AnalysisErrorSeverity.WARNING);
146 expect(error.type, AnalysisErrorType.STATIC_WARNING); 133 expect(error.type, AnalysisErrorType.STATIC_WARNING);
147 } 134 }
148 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698