| 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'; |
| 11 import 'package:analyzer/source/error_processor.dart'; | 11 import 'package:analyzer/source/error_processor.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/plugin/plugin_configuration.dart'; | |
| 16 import 'package:analyzer/src/services/lint.dart'; | 15 import 'package:analyzer/src/services/lint.dart'; |
| 17 import 'package:analyzer_cli/src/bootloader.dart'; | |
| 18 import 'package:analyzer_cli/src/driver.dart'; | 16 import 'package:analyzer_cli/src/driver.dart'; |
| 19 import 'package:analyzer_cli/src/options.dart'; | 17 import 'package:analyzer_cli/src/options.dart'; |
| 20 import 'package:path/path.dart' as path; | 18 import 'package:path/path.dart' as path; |
| 21 import 'package:plugin/plugin.dart'; | 19 import 'package:plugin/plugin.dart'; |
| 22 import 'package:unittest/unittest.dart'; | 20 import 'package:unittest/unittest.dart'; |
| 23 import 'package:yaml/src/yaml_node.dart'; | 21 import 'package:yaml/src/yaml_node.dart'; |
| 24 | 22 |
| 25 import 'utils.dart'; | 23 import 'utils.dart'; |
| 26 | 24 |
| 27 main() { | 25 main() { |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // String stdout = outSink.toString(); | 342 // String stdout = outSink.toString(); |
| 345 // expect(exitCode, 3); | 343 // expect(exitCode, 3); |
| 346 // expect( | 344 // expect( |
| 347 // stdout, | 345 // stdout, |
| 348 // contains( | 346 // contains( |
| 349 // 'Package root directory (does/not/exist) does not exist.')); | 347 // 'Package root directory (does/not/exist) does not exist.')); |
| 350 // }); | 348 // }); |
| 351 // }); | 349 // }); |
| 352 }); | 350 }); |
| 353 | 351 |
| 354 group('Bootloader', () { | 352 |
| 355 group('plugin processing', () { | |
| 356 test('bad format', () { | |
| 357 BootLoader loader = new BootLoader(); | |
| 358 loader.createImage([ | |
| 359 '--options', | |
| 360 path.join(testDirectory, 'data/bad_plugin_options.yaml'), | |
| 361 path.join(testDirectory, 'data/test_file.dart') | |
| 362 ]); | |
| 363 expect( | |
| 364 errorSink.toString(), | |
| 365 equals('Plugin configuration skipped: Unrecognized plugin config ' | |
| 366 'format, expected `YamlMap`, got `YamlList` ' | |
| 367 '(line 2, column 4)\n')); | |
| 368 }); | |
| 369 test('plugin config', () { | |
| 370 BootLoader loader = new BootLoader(); | |
| 371 Image image = loader.createImage([ | |
| 372 '--options', | |
| 373 path.join(testDirectory, 'data/plugin_options.yaml'), | |
| 374 path.join(testDirectory, 'data/test_file.dart') | |
| 375 ]); | |
| 376 var plugins = image.config.plugins; | |
| 377 expect(plugins, hasLength(1)); | |
| 378 expect(plugins.first.name, equals('my_plugin1')); | |
| 379 }); | |
| 380 group('plugin validation', () { | |
| 381 test('requires class name', () { | |
| 382 expect( | |
| 383 validate(new PluginInfo( | |
| 384 name: 'test_plugin', libraryUri: 'my_package/foo.dart')), | |
| 385 isNotNull); | |
| 386 }); | |
| 387 test('requires library URI', () { | |
| 388 expect( | |
| 389 validate( | |
| 390 new PluginInfo(name: 'test_plugin', className: 'MyPlugin')), | |
| 391 isNotNull); | |
| 392 }); | |
| 393 test('check', () { | |
| 394 expect( | |
| 395 validate(new PluginInfo( | |
| 396 name: 'test_plugin', | |
| 397 className: 'MyPlugin', | |
| 398 libraryUri: 'my_package/foo.dart')), | |
| 399 isNull); | |
| 400 }); | |
| 401 }); | |
| 402 }); | |
| 403 }); | |
| 404 } | 353 } |
| 405 | 354 |
| 406 const emptyOptionsFile = 'data/empty_options.yaml'; | 355 const emptyOptionsFile = 'data/empty_options.yaml'; |
| 407 | 356 |
| 408 /// Shared driver. | 357 /// Shared driver. |
| 409 Driver driver; | 358 Driver driver; |
| 410 | 359 |
| 411 List<ErrorProcessor> get processors => | 360 List<ErrorProcessor> get processors => |
| 412 driver.context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); | 361 driver.context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); |
| 413 | 362 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 this.options = options; | 414 this.options = options; |
| 466 } | 415 } |
| 467 } | 416 } |
| 468 | 417 |
| 469 class TestSource implements Source { | 418 class TestSource implements Source { |
| 470 TestSource(); | 419 TestSource(); |
| 471 | 420 |
| 472 @override | 421 @override |
| 473 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 422 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 474 } | 423 } |
| OLD | NEW |