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

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

Issue 1378503003: Suppress scanner errors for non-existent URIs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Review fix. 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/test_all.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
8 import 'package:analysis_server/src/domain_analysis.dart'; 8 import 'package:analysis_server/src/domain_analysis.dart';
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; 11 import 'package:test_reflective_loader/test_reflective_loader.dart';
11 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
12 13
13 import '../analysis_abstract.dart'; 14 import '../analysis_abstract.dart';
14 import '../utils.dart'; 15 import '../utils.dart';
15 16
16 main() { 17 main() {
17 initializeTestEnvironment(); 18 initializeTestEnvironment();
18 defineReflectiveTests(NotificationErrorsTest); 19 defineReflectiveTests(NotificationErrorsTest);
19 } 20 }
20 21
21 @reflectiveTest 22 @reflectiveTest
22 class NotificationErrorsTest extends AbstractAnalysisTest { 23 class NotificationErrorsTest extends AbstractAnalysisTest {
23 Map<String, List<AnalysisError>> filesErrors = {}; 24 Map<String, List<AnalysisError>> filesErrors = {};
24 25
25 void processNotification(Notification notification) { 26 void processNotification(Notification notification) {
26 if (notification.event == ANALYSIS_ERRORS) { 27 if (notification.event == ANALYSIS_ERRORS) {
27 var decoded = new AnalysisErrorsParams.fromNotification(notification); 28 var decoded = new AnalysisErrorsParams.fromNotification(notification);
28 filesErrors[decoded.file] = decoded.errors; 29 filesErrors[decoded.file] = decoded.errors;
29 } 30 }
30 } 31 }
31 32
32 @override 33 @override
33 void setUp() { 34 void setUp() {
34 super.setUp(); 35 super.setUp();
35 server.handlers = [new AnalysisDomainHandler(server),]; 36 server.handlers = [new AnalysisDomainHandler(server),];
36 } 37 }
37 38
39 test_importError() {
40 createProject();
41
42 addTestFile('''
43 import 'does_not_exist.dart';
44 ''');
45 return waitForTasksFinished().then((_) {
46 List<AnalysisError> errors = filesErrors[testFile];
47 // Verify that we are generating only 1 error for the bad URI.
48 // https://github.com/dart-lang/sdk/issues/23754
49 expect(errors, hasLength(1));
50 AnalysisError error = errors[0];
51 expect(error.severity, AnalysisErrorSeverity.ERROR);
52 expect(error.type, AnalysisErrorType.COMPILE_TIME_ERROR);
53 expect(error.message, startsWith('Target of URI does not exist'));
54 });
55 }
56
38 test_notInAnalysisRoot() { 57 test_notInAnalysisRoot() {
39 createProject(); 58 createProject();
40 String otherFile = '/other.dart'; 59 String otherFile = '/other.dart';
41 addFile(otherFile, 'UnknownType V;'); 60 addFile(otherFile, 'UnknownType V;');
42 addTestFile(''' 61 addTestFile('''
43 import '/other.dart'; 62 import '/other.dart';
44 63
45 main() { 64 main() {
46 print(V); 65 print(V);
47 } 66 }
(...skipping 28 matching lines...) Expand all
76 '''); 95 ''');
77 return waitForTasksFinished().then((_) { 96 return waitForTasksFinished().then((_) {
78 List<AnalysisError> errors = filesErrors[testFile]; 97 List<AnalysisError> errors = filesErrors[testFile];
79 expect(errors, hasLength(1)); 98 expect(errors, hasLength(1));
80 AnalysisError error = errors[0]; 99 AnalysisError error = errors[0];
81 expect(error.severity, AnalysisErrorSeverity.WARNING); 100 expect(error.severity, AnalysisErrorSeverity.WARNING);
82 expect(error.type, AnalysisErrorType.STATIC_WARNING); 101 expect(error.type, AnalysisErrorType.STATIC_WARNING);
83 }); 102 });
84 } 103 }
85 } 104 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698