OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer_cli.test.driver; | 5 library analyzer_cli.test.driver; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 expect(driver.context.analysisOptions.lint, isTrue); | 136 expect(driver.context.analysisOptions.lint, isTrue); |
137 | 137 |
138 /// The analysis options file only specifies 'camel_case_types'. | 138 /// The analysis options file only specifies 'camel_case_types'. |
139 var lintNames = getLints(driver.context).map((r) => r.name); | 139 var lintNames = getLints(driver.context).map((r) => r.name); |
140 expect(lintNames, orderedEquals(['camel_case_types'])); | 140 expect(lintNames, orderedEquals(['camel_case_types'])); |
141 }); | 141 }); |
142 | 142 |
143 test('generates lints', () async { | 143 test('generates lints', () async { |
144 await runLinter(); | 144 await runLinter(); |
145 expect(outSink.toString(), | 145 expect(outSink.toString(), |
146 contains('[lint] Name types using UpperCamelCase.')); | 146 contains('[lint] Name types using UpperCamelCase')); |
147 }); | 147 }); |
148 }); | 148 }); |
149 | 149 |
150 group('default lints - $designator', () { | 150 group('default lints - $designator', () { |
151 // Shared lint command. | 151 // Shared lint command. |
152 Future<Null> runLinter() async { | 152 Future<Null> runLinter() async { |
153 return await drive('data/linter_project/test_file.dart', | 153 return await drive('data/linter_project/test_file.dart', |
154 options: 'data/linter_project/$optionsFileName', | 154 options: 'data/linter_project/$optionsFileName', |
155 args: ['--lints']); | 155 args: ['--lints']); |
156 } | 156 } |
157 | 157 |
158 test('gets default lints', () async { | 158 test('gets default lints', () async { |
159 await runLinter(); | 159 await runLinter(); |
160 | 160 |
161 /// Lints should be enabled. | 161 /// Lints should be enabled. |
162 expect(driver.context.analysisOptions.lint, isTrue); | 162 expect(driver.context.analysisOptions.lint, isTrue); |
163 | 163 |
164 /// Default list should include camel_case_types. | 164 /// Default list should include camel_case_types. |
165 var lintNames = getLints(driver.context).map((r) => r.name); | 165 var lintNames = getLints(driver.context).map((r) => r.name); |
166 expect(lintNames, contains('camel_case_types')); | 166 expect(lintNames, contains('camel_case_types')); |
167 }); | 167 }); |
168 | 168 |
169 test('generates lints', () async { | 169 test('generates lints', () async { |
170 await runLinter(); | 170 await runLinter(); |
171 expect(outSink.toString(), | 171 expect(outSink.toString(), |
172 contains('[lint] Name types using UpperCamelCase.')); | 172 contains('[lint] Name types using UpperCamelCase')); |
173 }); | 173 }); |
174 }); | 174 }); |
175 | 175 |
176 group('no `--lints` flag (none in options) - $designator', () { | 176 group('no `--lints` flag (none in options) - $designator', () { |
177 // Shared lint command. | 177 // Shared lint command. |
178 Future<Null> runLinter() async { | 178 Future<Null> runLinter() async { |
179 return await drive('data/no_lints_project/test_file.dart', | 179 return await drive('data/no_lints_project/test_file.dart', |
180 options: 'data/no_lints_project/$optionsFileName'); | 180 options: 'data/no_lints_project/$optionsFileName'); |
181 } | 181 } |
182 | 182 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 path.join(testDir, 'lib', 'test_file.dart'), | 311 path.join(testDir, 'lib', 'test_file.dart'), |
312 args: [ | 312 args: [ |
313 '--fatal-warnings', | 313 '--fatal-warnings', |
314 '--packages', | 314 '--packages', |
315 path.join(testDir, '_packages'), | 315 path.join(testDir, '_packages'), |
316 ], | 316 ], |
317 options: path.join(testDir, '.analysis_options'), | 317 options: path.join(testDir, '.analysis_options'), |
318 ); | 318 ); |
319 expect(exitCode, 3); | 319 expect(exitCode, 3); |
320 expect(outSink.toString(), | 320 expect(outSink.toString(), |
321 contains('but doesn\'t end with a return statement.')); | 321 contains('but doesn\'t end with a return statement')); |
322 expect(outSink.toString(), contains('isn\'t defined')); | 322 expect(outSink.toString(), contains('isn\'t defined')); |
323 expect(outSink.toString(), contains('Avoid empty else statements.')); | 323 expect(outSink.toString(), contains('Avoid empty else statements')); |
324 }); | 324 }); |
325 | 325 |
326 test('test strong SDK', () async { | 326 test('test strong SDK', () async { |
327 String testDir = path.join(testDirectory, 'data', 'strong_sdk'); | 327 String testDir = path.join(testDirectory, 'data', 'strong_sdk'); |
328 await drive(path.join(testDir, 'main.dart'), args: ['--strong']); | 328 await drive(path.join(testDir, 'main.dart'), args: ['--strong']); |
329 expect(driver.context.analysisOptions.strongMode, isTrue); | 329 expect(driver.context.analysisOptions.strongMode, isTrue); |
330 expect(outSink.toString(), contains('No issues found')); | 330 expect(outSink.toString(), contains('No issues found')); |
331 expect(exitCode, 0); | 331 expect(exitCode, 0); |
332 }); | 332 }); |
333 }); | 333 }); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 527 |
528 ErrorProcessor processorFor(AnalysisError error) => | 528 ErrorProcessor processorFor(AnalysisError error) => |
529 processors.firstWhere((p) => p.appliesTo(error)); | 529 processors.firstWhere((p) => p.appliesTo(error)); |
530 | 530 |
531 class TestSource implements Source { | 531 class TestSource implements Source { |
532 TestSource(); | 532 TestSource(); |
533 | 533 |
534 @override | 534 @override |
535 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 535 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
536 } | 536 } |
OLD | NEW |