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

Side by Side Diff: test/driver_test.dart

Issue 1378193004: Fix Analysis Engine plugin setup. (Closed) Base URL: https://github.com/dart-lang/analyzer_cli.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « lib/src/driver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 @TestOn("vm") 5 @TestOn("vm")
6 library analyzer_cli.test.driver; 6 library analyzer_cli.test.driver;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:analyzer/plugin/options.dart'; 10 import 'package:analyzer/plugin/options.dart';
(...skipping 17 matching lines...) Expand all
28 '--options', 28 '--options',
29 'test/data/test_options.yaml', 29 'test/data/test_options.yaml',
30 'test/data/test_file.dart' 30 'test/data/test_file.dart'
31 ]); 31 ]);
32 expect(processor.options['test_plugin'], isNotNull); 32 expect(processor.options['test_plugin'], isNotNull);
33 expect(processor.exception, isNull); 33 expect(processor.exception, isNull);
34 }); 34 });
35 }); 35 });
36 36
37 group('linter', () { 37 group('linter', () {
38 test('gets analysis options', () { 38 StringSink savedOutSink;
39 Driver driver = new Driver(); 39 Driver driver;
40
41 setUp(() {
42 savedOutSink = outSink;
43 outSink = new StringBuffer();
44
45 driver = new Driver();
40 driver.start([ 46 driver.start([
41 '--options', 47 '--options',
42 'test/data/linter_project/.analysis_options', 48 'test/data/linter_project/.analysis_options',
43 '--lints', 49 '--lints',
44 'test/data/linter_project/test_file.dart' 50 'test/data/linter_project/test_file.dart'
45 ]); 51 ]);
52 });
53 tearDown(() {
54 outSink = savedOutSink;
55 });
46 56
57 test('gets analysis options', () {
47 /// Lints should be enabled. 58 /// Lints should be enabled.
48 expect(driver.context.analysisOptions.lint, isTrue); 59 expect(driver.context.analysisOptions.lint, isTrue);
49 60
50 /// The .analysis_options file only specifies 'camel_case_types'. 61 /// The .analysis_options file only specifies 'camel_case_types'.
51 var lintNames = linterPlugin.lintRules.map((r) => r.name); 62 var lintNames = linterPlugin.lintRules.map((r) => r.name);
52 expect(lintNames, orderedEquals(['camel_case_types'])); 63 expect(lintNames, orderedEquals(['camel_case_types']));
53 }); 64 });
65
66 test('generates lints', () {
67 expect(outSink.toString(),
68 contains('[lint] Name types using UpperCamelCase.'));
69 });
54 }); 70 });
55 71
56 group('in temp directory', () { 72 group('in temp directory', () {
57 StringSink savedOutSink, savedErrorSink; 73 StringSink savedOutSink, savedErrorSink;
58 int savedExitCode; 74 int savedExitCode;
59 Directory savedCurrentDirectory; 75 Directory savedCurrentDirectory;
60 Directory tempDir; 76 Directory tempDir;
61 setUp(() { 77 setUp(() {
62 savedOutSink = outSink; 78 savedOutSink = outSink;
63 savedErrorSink = errorSink; 79 savedErrorSink = errorSink;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 }); 148 });
133 test('bad format', () { 149 test('bad format', () {
134 BootLoader loader = new BootLoader(); 150 BootLoader loader = new BootLoader();
135 loader.createImage([ 151 loader.createImage([
136 '--options', 152 '--options',
137 'test/data/bad_plugin_options.yaml', 153 'test/data/bad_plugin_options.yaml',
138 'test/data/test_file.dart' 154 'test/data/test_file.dart'
139 ]); 155 ]);
140 expect( 156 expect(
141 errorSink.toString(), 157 errorSink.toString(),
142 equals( 158 equals('Plugin configuration skipped: Unrecognized plugin config '
143 'Plugin configuration skipped: Unrecognized plugin config format , expected `YamlMap`, got `YamlList` (line 2, column 4)\n')); 159 'format, expected `YamlMap`, got `YamlList` (line 2, column 4)\n '));
144 }); 160 });
145 test('plugin config', () { 161 test('plugin config', () {
146 BootLoader loader = new BootLoader(); 162 BootLoader loader = new BootLoader();
147 Image image = loader.createImage([ 163 Image image = loader.createImage([
148 '--options', 164 '--options',
149 'test/data/plugin_options.yaml', 165 'test/data/plugin_options.yaml',
150 'test/data/test_file.dart' 166 'test/data/test_file.dart'
151 ]); 167 ]);
152 var plugins = image.config.plugins; 168 var plugins = image.config.plugins;
153 expect(plugins, hasLength(1)); 169 expect(plugins, hasLength(1));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 @override 220 @override
205 void onError(Exception exception) { 221 void onError(Exception exception) {
206 this.exception = exception; 222 this.exception = exception;
207 } 223 }
208 224
209 @override 225 @override
210 void optionsProcessed(Map<String, YamlNode> options) { 226 void optionsProcessed(Map<String, YamlNode> options) {
211 this.options = options; 227 this.options = options;
212 } 228 }
213 } 229 }
OLDNEW
« no previous file with comments | « lib/src/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698