| 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:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analyzer/plugin/options.dart'; | 9 import 'package:analyzer/plugin/options.dart'; |
| 10 import 'package:analyzer/source/analysis_options_provider.dart'; | 10 import 'package:analyzer/source/analysis_options_provider.dart'; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // missing_return: error | 245 // missing_return: error |
| 246 var missing_return = new AnalysisError( | 246 var missing_return = new AnalysisError( |
| 247 new TestSource(), 0, 1, HintCode.MISSING_RETURN, [ | 247 new TestSource(), 0, 1, HintCode.MISSING_RETURN, [ |
| 248 ['x'] | 248 ['x'] |
| 249 ]); | 249 ]); |
| 250 expect(processorFor(missing_return).severity, ErrorSeverity.ERROR); | 250 expect(processorFor(missing_return).severity, ErrorSeverity.ERROR); |
| 251 expect( | 251 expect( |
| 252 outSink.toString(), | 252 outSink.toString(), |
| 253 contains( | 253 contains( |
| 254 "[error] This function declares a return type of 'int'")); | 254 "[error] This function declares a return type of 'int'")); |
| 255 expect(outSink.toString(), | 255 expect(outSink.toString(), contains("1 error and 1 warning found.")); |
| 256 contains("1 error and 1 warning found.")); | |
| 257 }); | 256 }); |
| 258 | 257 |
| 259 test('language', () { | 258 test('language', () { |
| 260 doDrive(); | 259 doDrive(); |
| 261 expect(driver.context.analysisOptions.enableSuperMixins, isTrue); | 260 expect(driver.context.analysisOptions.enableSuperMixins, isTrue); |
| 262 }); | 261 }); |
| 263 }); | 262 }); |
| 264 | 263 |
| 265 group('with flags', () { | 264 group('with flags', () { |
| 266 // Shared driver command. | 265 // Shared driver command. |
| 267 var doDrive = () => drive('data/options_tests_project/test_file.dart', | 266 var doDrive = () => drive('data/options_tests_project/test_file.dart', |
| 268 args: ['--fatal-warnings'], | 267 args: ['--fatal-warnings'], |
| 269 options: 'data/options_tests_project/.analysis_options'); | 268 options: 'data/options_tests_project/.analysis_options'); |
| 270 | 269 |
| 271 test('override fatal warning', () { | 270 test('override fatal warning', () { |
| 272 doDrive(); | 271 doDrive(); |
| 273 // missing_return: error | 272 // missing_return: error |
| 274 var undefined_function = new AnalysisError(new TestSource(), 0, 1, | 273 var undefined_function = new AnalysisError(new TestSource(), 0, 1, |
| 275 StaticTypeWarningCode.UNDEFINED_FUNCTION, [ | 274 StaticTypeWarningCode.UNDEFINED_FUNCTION, [ |
| 276 ['x'] | 275 ['x'] |
| 277 ]); | 276 ]); |
| 278 expect( | 277 expect( |
| 279 processorFor(undefined_function).severity, ErrorSeverity.WARNING); | 278 processorFor(undefined_function).severity, ErrorSeverity.WARNING); |
| 280 // Should not be made fatal by `--fatal-warnings`. | 279 // Should not be made fatal by `--fatal-warnings`. |
| 281 expect(outSink.toString(), | 280 expect(outSink.toString(), |
| 282 contains("[warning] The function 'baz' is not defined")); | 281 contains("[warning] The function 'baz' is not defined")); |
| 283 expect(outSink.toString(), | 282 expect(outSink.toString(), contains("1 error and 1 warning found.")); |
| 284 contains("1 error and 1 warning found.")); | |
| 285 }); | 283 }); |
| 286 }); | 284 }); |
| 287 }); | 285 }); |
| 288 | 286 |
| 287 group('package-mode', () { |
| 288 // Shared driver command. |
| 289 var doDrive = () => drive('data/options_tests_project/test_file.dart', |
| 290 args: ['--package-mode', '--machine'], |
| 291 options: 'data/options_tests_project/.analysis_options'); |
| 292 |
| 293 test('no stats', () { |
| 294 doDrive(); |
| 295 // Should not print stat summary. |
| 296 expect(outSink.toString(), isEmpty); |
| 297 }); |
| 298 }); |
| 299 |
| 289 //TODO(pq): fix to be bot-friendly (sdk#25258). | 300 //TODO(pq): fix to be bot-friendly (sdk#25258). |
| 290 // group('in temp directory', () { | 301 // group('in temp directory', () { |
| 291 // Directory savedCurrentDirectory; | 302 // Directory savedCurrentDirectory; |
| 292 // Directory tempDir; | 303 // Directory tempDir; |
| 293 // setUp(() { | 304 // setUp(() { |
| 294 // // Call base setUp. | 305 // // Call base setUp. |
| 295 // _setUp(); | 306 // _setUp(); |
| 296 // savedCurrentDirectory = Directory.current; | 307 // savedCurrentDirectory = Directory.current; |
| 297 // tempDir = Directory.systemTemp.createTempSync('analyzer_'); | 308 // tempDir = Directory.systemTemp.createTempSync('analyzer_'); |
| 298 // }); | 309 // }); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 // new Driver().start(['--package-root', 'does/not/exist', 'test.dart']); | 352 // new Driver().start(['--package-root', 'does/not/exist', 'test.dart']); |
| 342 // String stdout = outSink.toString(); | 353 // String stdout = outSink.toString(); |
| 343 // expect(exitCode, 3); | 354 // expect(exitCode, 3); |
| 344 // expect( | 355 // expect( |
| 345 // stdout, | 356 // stdout, |
| 346 // contains( | 357 // contains( |
| 347 // 'Package root directory (does/not/exist) does not exist.')); | 358 // 'Package root directory (does/not/exist) does not exist.')); |
| 348 // }); | 359 // }); |
| 349 // }); | 360 // }); |
| 350 }); | 361 }); |
| 351 | |
| 352 | |
| 353 } | 362 } |
| 354 | 363 |
| 355 const emptyOptionsFile = 'data/empty_options.yaml'; | 364 const emptyOptionsFile = 'data/empty_options.yaml'; |
| 356 | 365 |
| 357 /// Shared driver. | 366 /// Shared driver. |
| 358 Driver driver; | 367 Driver driver; |
| 359 | 368 |
| 360 List<ErrorProcessor> get processors => | 369 List<ErrorProcessor> get processors => |
| 361 driver.context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); | 370 driver.context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); |
| 362 | 371 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 this.options = options; | 423 this.options = options; |
| 415 } | 424 } |
| 416 } | 425 } |
| 417 | 426 |
| 418 class TestSource implements Source { | 427 class TestSource implements Source { |
| 419 TestSource(); | 428 TestSource(); |
| 420 | 429 |
| 421 @override | 430 @override |
| 422 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 431 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 423 } | 432 } |
| OLD | NEW |