| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library analyzer_cli.test.boot_loader_test; | |
| 6 | |
| 7 import 'dart:io'; | |
| 8 | |
| 9 import 'package:analyzer/src/plugin/plugin_configuration.dart'; | |
| 10 import 'package:analyzer_cli/src/boot_loader.dart'; | |
| 11 import 'package:analyzer_cli/src/driver.dart'; | |
| 12 import 'package:analyzer_cli/src/options.dart'; | |
| 13 import 'package:path/path.dart' as path; | |
| 14 import 'package:test/test.dart'; | |
| 15 | |
| 16 import 'utils.dart'; | |
| 17 | |
| 18 main() { | |
| 19 StringSink savedOutSink, savedErrorSink; | |
| 20 int savedExitCode; | |
| 21 ExitHandler savedExitHandler; | |
| 22 | |
| 23 /// Base setup. | |
| 24 _setUp() { | |
| 25 savedOutSink = outSink; | |
| 26 savedErrorSink = errorSink; | |
| 27 savedExitHandler = exitHandler; | |
| 28 savedExitCode = exitCode; | |
| 29 exitHandler = (code) => exitCode = code; | |
| 30 outSink = new StringBuffer(); | |
| 31 errorSink = new StringBuffer(); | |
| 32 } | |
| 33 | |
| 34 /// Base teardown. | |
| 35 _tearDown() { | |
| 36 outSink = savedOutSink; | |
| 37 errorSink = savedErrorSink; | |
| 38 exitCode = savedExitCode; | |
| 39 exitHandler = savedExitHandler; | |
| 40 } | |
| 41 | |
| 42 setUp(() => _setUp()); | |
| 43 | |
| 44 tearDown(() => _tearDown()); | |
| 45 | |
| 46 group('Bootloader', () { | |
| 47 group('plugin processing', () { | |
| 48 test('bad format', () { | |
| 49 BootLoader loader = new BootLoader(); | |
| 50 loader.createImage([ | |
| 51 '--options', | |
| 52 path.join(testDirectory, 'data/bad_plugin_options.yaml'), | |
| 53 path.join(testDirectory, 'data/test_file.dart') | |
| 54 ]); | |
| 55 expect( | |
| 56 errorSink.toString(), | |
| 57 'Plugin configuration skipped: Unrecognized plugin config ' | |
| 58 'format, expected `YamlMap`, got `YamlList` ' | |
| 59 '(line 2, column 4)\n'); | |
| 60 }); | |
| 61 test('plugin config', () { | |
| 62 BootLoader loader = new BootLoader(); | |
| 63 Image image = loader.createImage([ | |
| 64 '--options', | |
| 65 path.join(testDirectory, 'data/plugin_options.yaml'), | |
| 66 path.join(testDirectory, 'data/test_file.dart') | |
| 67 ]); | |
| 68 var plugins = image.config.plugins; | |
| 69 expect(plugins, hasLength(1)); | |
| 70 expect(plugins.first.name, 'my_plugin1'); | |
| 71 }); | |
| 72 group('plugin validation', () { | |
| 73 test('requires class name', () { | |
| 74 expect( | |
| 75 validate(new PluginInfo( | |
| 76 name: 'test_plugin', libraryUri: 'my_package/foo.dart')), | |
| 77 isNotNull); | |
| 78 }); | |
| 79 test('requires library URI', () { | |
| 80 expect( | |
| 81 validate( | |
| 82 new PluginInfo(name: 'test_plugin', className: 'MyPlugin')), | |
| 83 isNotNull); | |
| 84 }); | |
| 85 test('check', () { | |
| 86 expect( | |
| 87 validate(new PluginInfo( | |
| 88 name: 'test_plugin', | |
| 89 className: 'MyPlugin', | |
| 90 libraryUri: 'my_package/foo.dart')), | |
| 91 isNull); | |
| 92 }); | |
| 93 }); | |
| 94 }); | |
| 95 }); | |
| 96 } | |
| OLD | NEW |