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

Side by Side Diff: pkg/analysis_server/test/integration/analysis/lint_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
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 import 'package:analyzer/src/generated/engine.dart'; 5 import 'package:analyzer/src/generated/engine.dart';
6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 6 import 'package:analyzer_plugin/protocol/protocol_common.dart';
7 import 'package:test/test.dart'; 7 import 'package:test/test.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; 8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 9
10 import '../support/integration_tests.dart'; 10 import '../support/integration_tests.dart';
11 11
12 main() { 12 main() {
13 defineReflectiveSuite(() { 13 defineReflectiveSuite(() {
14 defineReflectiveTests(LintIntegrationTest); 14 defineReflectiveTests(LintIntegrationTest);
15 }); 15 });
16 } 16 }
17 17
18 @reflectiveTest 18 @reflectiveTest
19 class LintIntegrationTest extends AbstractAnalysisServerIntegrationTest { 19 class LintIntegrationTest extends AbstractAnalysisServerIntegrationTest {
20 test_no_lints_when_not_specified() async { 20 test_no_lints_when_not_specified() async {
21 String source = sourcePath('test.dart'); 21 String source = sourcePath('test.dart');
22 writeFile( 22 writeFile(source, '''
23 source,
24 '''
25 class abc { // lint: not CamelCase (should get ignored though) 23 class abc { // lint: not CamelCase (should get ignored though)
26 }'''); 24 }''');
27 standardAnalysisSetup(); 25 standardAnalysisSetup();
28 26
29 await analysisFinished; 27 await analysisFinished;
30 expect(currentAnalysisErrors[source], isList); 28 expect(currentAnalysisErrors[source], isList);
31 // Should be empty without an analysis options file. 29 // Should be empty without an analysis options file.
32 List<AnalysisError> errors = currentAnalysisErrors[source]; 30 List<AnalysisError> errors = currentAnalysisErrors[source];
33 expect(errors, hasLength(0)); 31 expect(errors, hasLength(0));
34 } 32 }
35 33
36 test_simple_lint_newOptionsFile() async { 34 test_simple_lint_newOptionsFile() async {
37 writeFile( 35 writeFile(sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE), '''
38 sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE),
39 '''
40 linter: 36 linter:
41 rules: 37 rules:
42 - camel_case_types 38 - camel_case_types
43 '''); 39 ''');
44 40
45 String source = sourcePath('test.dart'); 41 String source = sourcePath('test.dart');
46 writeFile( 42 writeFile(source, '''
47 source,
48 '''
49 class a { // lint: not CamelCase 43 class a { // lint: not CamelCase
50 }'''); 44 }''');
51 45
52 standardAnalysisSetup(); 46 standardAnalysisSetup();
53 47
54 await analysisFinished; 48 await analysisFinished;
55 49
56 expect(currentAnalysisErrors[source], isList); 50 expect(currentAnalysisErrors[source], isList);
57 List<AnalysisError> errors = currentAnalysisErrors[source]; 51 List<AnalysisError> errors = currentAnalysisErrors[source];
58 expect(errors, hasLength(1)); 52 expect(errors, hasLength(1));
59 AnalysisError error = errors[0]; 53 AnalysisError error = errors[0];
60 expect(error.location.file, source); 54 expect(error.location.file, source);
61 expect(error.severity, AnalysisErrorSeverity.INFO); 55 expect(error.severity, AnalysisErrorSeverity.INFO);
62 expect(error.type, AnalysisErrorType.LINT); 56 expect(error.type, AnalysisErrorType.LINT);
63 } 57 }
64 58
65 test_simple_lint_oldOptionsFile() async { 59 test_simple_lint_oldOptionsFile() async {
66 writeFile( 60 writeFile(sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_FILE), '''
67 sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_FILE),
68 '''
69 linter: 61 linter:
70 rules: 62 rules:
71 - camel_case_types 63 - camel_case_types
72 '''); 64 ''');
73 65
74 String source = sourcePath('test.dart'); 66 String source = sourcePath('test.dart');
75 writeFile( 67 writeFile(source, '''
76 source,
77 '''
78 class a { // lint: not CamelCase 68 class a { // lint: not CamelCase
79 }'''); 69 }''');
80 70
81 standardAnalysisSetup(); 71 standardAnalysisSetup();
82 72
83 await analysisFinished; 73 await analysisFinished;
84 74
85 expect(currentAnalysisErrors[source], isList); 75 expect(currentAnalysisErrors[source], isList);
86 List<AnalysisError> errors = currentAnalysisErrors[source]; 76 List<AnalysisError> errors = currentAnalysisErrors[source];
87 expect(errors, hasLength(1)); 77 expect(errors, hasLength(1));
88 AnalysisError error = errors[0]; 78 AnalysisError error = errors[0];
89 expect(error.location.file, source); 79 expect(error.location.file, source);
90 expect(error.severity, AnalysisErrorSeverity.INFO); 80 expect(error.severity, AnalysisErrorSeverity.INFO);
91 expect(error.type, AnalysisErrorType.LINT); 81 expect(error.type, AnalysisErrorType.LINT);
92 } 82 }
93 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698