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:io'; | 8 import 'dart:io'; |
8 | 9 |
9 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
10 import 'package:analyzer/source/analysis_options_provider.dart'; | 11 import 'package:analyzer/source/analysis_options_provider.dart'; |
11 import 'package:analyzer/source/error_processor.dart'; | 12 import 'package:analyzer/source/error_processor.dart'; |
12 import 'package:analyzer/src/error/codes.dart'; | 13 import 'package:analyzer/src/error/codes.dart'; |
13 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
14 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
15 import 'package:analyzer/src/services/lint.dart'; | 16 import 'package:analyzer/src/services/lint.dart'; |
16 import 'package:analyzer_cli/src/driver.dart'; | 17 import 'package:analyzer_cli/src/driver.dart'; |
(...skipping 27 matching lines...) Expand all Loading... |
44 exitCode = savedExitCode; | 45 exitCode = savedExitCode; |
45 exitHandler = savedExitHandler; | 46 exitHandler = savedExitHandler; |
46 } | 47 } |
47 | 48 |
48 setUp(() => _setUp()); | 49 setUp(() => _setUp()); |
49 | 50 |
50 tearDown(() => _tearDown()); | 51 tearDown(() => _tearDown()); |
51 | 52 |
52 group('Driver', () { | 53 group('Driver', () { |
53 group('options', () { | 54 group('options', () { |
54 test('todos', () { | 55 test('todos', () async { |
55 drive('data/file_with_todo.dart'); | 56 await drive('data/file_with_todo.dart'); |
56 expect(outSink.toString().contains('[info]'), isFalse); | 57 expect(outSink.toString().contains('[info]'), isFalse); |
57 }); | 58 }); |
58 }); | 59 }); |
59 | 60 |
60 group('exit codes', () { | 61 group('exit codes', () { |
61 test('fatal hints', () { | 62 test('fatal hints', () async { |
62 drive('data/file_with_hint.dart', args: ['--fatal-hints']); | 63 await drive('data/file_with_hint.dart', args: ['--fatal-hints']); |
63 expect(exitCode, 3); | 64 expect(exitCode, 3); |
64 }); | 65 }); |
65 | 66 |
66 test('not fatal hints', () { | 67 test('not fatal hints', () async { |
67 drive('data/file_with_hint.dart'); | 68 await drive('data/file_with_hint.dart'); |
68 expect(exitCode, 0); | 69 expect(exitCode, 0); |
69 }); | 70 }); |
70 | 71 |
71 test('fatal errors', () { | 72 test('fatal errors', () async { |
72 drive('data/file_with_error.dart'); | 73 await drive('data/file_with_error.dart'); |
73 expect(exitCode, 3); | 74 expect(exitCode, 3); |
74 }); | 75 }); |
75 | 76 |
76 test('not fatal warnings', () { | 77 test('not fatal warnings', () async { |
77 drive('data/file_with_warning.dart'); | 78 await drive('data/file_with_warning.dart'); |
78 expect(exitCode, 0); | 79 expect(exitCode, 0); |
79 }); | 80 }); |
80 | 81 |
81 test('fatal warnings', () { | 82 test('fatal warnings', () async { |
82 drive('data/file_with_warning.dart', args: ['--fatal-warnings']); | 83 await drive('data/file_with_warning.dart', args: ['--fatal-warnings']); |
83 expect(exitCode, 3); | 84 expect(exitCode, 3); |
84 }); | 85 }); |
85 | 86 |
86 test('missing options file', () { | 87 test('missing options file', () async { |
87 drive('data/test_file.dart', options: 'data/NO_OPTIONS_HERE'); | 88 await drive('data/test_file.dart', options: 'data/NO_OPTIONS_HERE'); |
88 expect(exitCode, 3); | 89 expect(exitCode, 3); |
89 }); | 90 }); |
90 | 91 |
91 test('missing dart file', () { | 92 test('missing dart file', () async { |
92 drive('data/NO_DART_FILE_HERE.dart'); | 93 await drive('data/NO_DART_FILE_HERE.dart'); |
93 expect(exitCode, 3); | 94 expect(exitCode, 3); |
94 }); | 95 }); |
95 | 96 |
96 test('part file', () { | 97 test('part file', () async { |
97 drive('data/library_and_parts/part2.dart'); | 98 await drive('data/library_and_parts/part2.dart'); |
98 expect(exitCode, 3); | 99 expect(exitCode, 3); |
99 }); | 100 }); |
100 | 101 |
101 test('non-dangling part file', () { | 102 test('non-dangling part file', () async { |
102 Driver driver = new Driver(); | 103 Driver driver = new Driver(); |
103 driver.start([ | 104 await driver.start([ |
104 path.join(testDirectory, 'data/library_and_parts/lib.dart'), | 105 path.join(testDirectory, 'data/library_and_parts/lib.dart'), |
105 path.join(testDirectory, 'data/library_and_parts/part1.dart') | 106 path.join(testDirectory, 'data/library_and_parts/part1.dart') |
106 ]); | 107 ]); |
107 expect(exitCode, 0); | 108 expect(exitCode, 0); |
108 }); | 109 }); |
109 | 110 |
110 test('extra part file', () { | 111 test('extra part file', () async { |
111 Driver driver = new Driver(); | 112 Driver driver = new Driver(); |
112 driver.start([ | 113 await driver.start([ |
113 path.join(testDirectory, 'data/library_and_parts/lib.dart'), | 114 path.join(testDirectory, 'data/library_and_parts/lib.dart'), |
114 path.join(testDirectory, 'data/library_and_parts/part1.dart'), | 115 path.join(testDirectory, 'data/library_and_parts/part1.dart'), |
115 path.join(testDirectory, 'data/library_and_parts/part2.dart') | 116 path.join(testDirectory, 'data/library_and_parts/part2.dart') |
116 ]); | 117 ]); |
117 expect(exitCode, 3); | 118 expect(exitCode, 3); |
118 }); | 119 }); |
119 }); | 120 }); |
120 | 121 |
121 group('linter', () { | 122 group('linter', () { |
122 void createTests(String designator, String optionsFileName) { | 123 void createTests(String designator, String optionsFileName) { |
123 group('lints in options - $designator', () { | 124 group('lints in options - $designator', () { |
124 // Shared lint command. | 125 // Shared lint command. |
125 void runLinter() => drive('data/linter_project/test_file.dart', | 126 Future<Null> runLinter() async { |
126 options: 'data/linter_project/$optionsFileName', | 127 return await drive('data/linter_project/test_file.dart', |
127 args: ['--lints']); | 128 options: 'data/linter_project/$optionsFileName', |
| 129 args: ['--lints']); |
| 130 } |
128 | 131 |
129 test('gets analysis options', () { | 132 test('gets analysis options', () async { |
130 runLinter(); | 133 await runLinter(); |
131 | 134 |
132 /// Lints should be enabled. | 135 /// Lints should be enabled. |
133 expect(driver.context.analysisOptions.lint, isTrue); | 136 expect(driver.context.analysisOptions.lint, isTrue); |
134 | 137 |
135 /// The analysis options file only specifies 'camel_case_types'. | 138 /// The analysis options file only specifies 'camel_case_types'. |
136 var lintNames = getLints(driver.context).map((r) => r.name); | 139 var lintNames = getLints(driver.context).map((r) => r.name); |
137 expect(lintNames, orderedEquals(['camel_case_types'])); | 140 expect(lintNames, orderedEquals(['camel_case_types'])); |
138 }); | 141 }); |
139 | 142 |
140 test('generates lints', () { | 143 test('generates lints', () async { |
141 runLinter(); | 144 await runLinter(); |
142 expect(outSink.toString(), | 145 expect(outSink.toString(), |
143 contains('[lint] Name types using UpperCamelCase.')); | 146 contains('[lint] Name types using UpperCamelCase.')); |
144 }); | 147 }); |
145 }); | 148 }); |
146 | 149 |
147 group('default lints - $designator', () { | 150 group('default lints - $designator', () { |
148 // Shared lint command. | 151 // Shared lint command. |
149 void runLinter() => drive('data/linter_project/test_file.dart', | 152 Future<Null> runLinter() async { |
150 options: 'data/linter_project/$optionsFileName', | 153 return await drive('data/linter_project/test_file.dart', |
151 args: ['--lints']); | 154 options: 'data/linter_project/$optionsFileName', |
| 155 args: ['--lints']); |
| 156 } |
152 | 157 |
153 test('gets default lints', () { | 158 test('gets default lints', () async { |
154 runLinter(); | 159 await runLinter(); |
155 | 160 |
156 /// Lints should be enabled. | 161 /// Lints should be enabled. |
157 expect(driver.context.analysisOptions.lint, isTrue); | 162 expect(driver.context.analysisOptions.lint, isTrue); |
158 | 163 |
159 /// Default list should include camel_case_types. | 164 /// Default list should include camel_case_types. |
160 var lintNames = getLints(driver.context).map((r) => r.name); | 165 var lintNames = getLints(driver.context).map((r) => r.name); |
161 expect(lintNames, contains('camel_case_types')); | 166 expect(lintNames, contains('camel_case_types')); |
162 }); | 167 }); |
163 | 168 |
164 test('generates lints', () { | 169 test('generates lints', () async { |
165 runLinter(); | 170 await runLinter(); |
166 expect(outSink.toString(), | 171 expect(outSink.toString(), |
167 contains('[lint] Name types using UpperCamelCase.')); | 172 contains('[lint] Name types using UpperCamelCase.')); |
168 }); | 173 }); |
169 }); | 174 }); |
170 | 175 |
171 group('no `--lints` flag (none in options) - $designator', () { | 176 group('no `--lints` flag (none in options) - $designator', () { |
172 // Shared lint command. | 177 // Shared lint command. |
173 void runLinter() => drive('data/no_lints_project/test_file.dart', | 178 Future<Null> runLinter() async { |
174 options: 'data/no_lints_project/$optionsFileName'); | 179 return await drive('data/no_lints_project/test_file.dart', |
| 180 options: 'data/no_lints_project/$optionsFileName'); |
| 181 } |
175 | 182 |
176 test('lints disabled', () { | 183 test('lints disabled', () async { |
177 runLinter(); | 184 await runLinter(); |
178 expect(driver.context.analysisOptions.lint, isFalse); | 185 expect(driver.context.analysisOptions.lint, isFalse); |
179 }); | 186 }); |
180 | 187 |
181 test('no registered lints', () { | 188 test('no registered lints', () async { |
182 runLinter(); | 189 await runLinter(); |
183 expect(getLints(driver.context), isEmpty); | 190 expect(getLints(driver.context), isEmpty); |
184 }); | 191 }); |
185 | 192 |
186 test('no generated warnings', () { | 193 test('no generated warnings', () async { |
187 runLinter(); | 194 await runLinter(); |
188 expect(outSink.toString(), contains('No issues found')); | 195 expect(outSink.toString(), contains('No issues found')); |
189 }); | 196 }); |
190 }); | 197 }); |
191 } | 198 } |
192 | 199 |
193 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); | 200 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); |
194 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 201 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
195 }); | 202 }); |
196 | 203 |
197 test('containsLintRuleEntry', () { | 204 test('containsLintRuleEntry', () { |
(...skipping 18 matching lines...) Expand all Loading... |
216 # rules: | 223 # rules: |
217 # - foo | 224 # - foo |
218 '''); | 225 '''); |
219 expect(containsLintRuleEntry(options), false); | 226 expect(containsLintRuleEntry(options), false); |
220 }); | 227 }); |
221 | 228 |
222 group('options processing', () { | 229 group('options processing', () { |
223 void createTests(String designator, String optionsFileName) { | 230 void createTests(String designator, String optionsFileName) { |
224 group('basic config - $designator', () { | 231 group('basic config - $designator', () { |
225 // Shared driver command. | 232 // Shared driver command. |
226 void doDrive() => drive('data/options_tests_project/test_file.dart', | 233 Future<Null> doDrive() async { |
227 options: 'data/options_tests_project/$optionsFileName'); | 234 await drive('data/options_tests_project/test_file.dart', |
| 235 options: 'data/options_tests_project/$optionsFileName'); |
| 236 } |
228 | 237 |
229 test('filters', () { | 238 test('filters', () async { |
230 doDrive(); | 239 await doDrive(); |
231 expect(processors, hasLength(3)); | 240 expect(processors, hasLength(3)); |
232 | 241 |
233 // unused_local_variable: ignore | 242 // unused_local_variable: ignore |
234 var unused_local_variable = new AnalysisError( | 243 var unused_local_variable = new AnalysisError( |
235 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ | 244 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ |
236 ['x'] | 245 ['x'] |
237 ]); | 246 ]); |
238 expect(processorFor(unused_local_variable).severity, isNull); | 247 expect(processorFor(unused_local_variable).severity, isNull); |
239 | 248 |
240 // missing_return: error | 249 // missing_return: error |
241 var missing_return = new AnalysisError( | 250 var missing_return = new AnalysisError( |
242 new TestSource(), 0, 1, HintCode.MISSING_RETURN, [ | 251 new TestSource(), 0, 1, HintCode.MISSING_RETURN, [ |
243 ['x'] | 252 ['x'] |
244 ]); | 253 ]); |
245 expect(processorFor(missing_return).severity, ErrorSeverity.ERROR); | 254 expect(processorFor(missing_return).severity, ErrorSeverity.ERROR); |
246 expect( | 255 expect( |
247 outSink.toString(), | 256 outSink.toString(), |
248 contains( | 257 contains( |
249 "[error] This function declares a return type of 'int'")); | 258 "[error] This function declares a return type of 'int'")); |
250 expect( | 259 expect( |
251 outSink.toString(), contains("1 error and 1 warning found.")); | 260 outSink.toString(), contains("1 error and 1 warning found.")); |
252 }); | 261 }); |
253 | 262 |
254 test('language', () { | 263 test('language', () async { |
255 doDrive(); | 264 await doDrive(); |
256 expect(driver.context.analysisOptions.enableSuperMixins, isTrue); | 265 expect(driver.context.analysisOptions.enableSuperMixins, isTrue); |
257 }); | 266 }); |
258 | 267 |
259 test('strongMode', () { | 268 test('strongMode', () async { |
260 doDrive(); | 269 await doDrive(); |
261 expect(driver.context.analysisOptions.strongMode, isTrue); | 270 expect(driver.context.analysisOptions.strongMode, isTrue); |
262 //https://github.com/dart-lang/sdk/issues/26129 | 271 //https://github.com/dart-lang/sdk/issues/26129 |
263 AnalysisContext sdkContext = | 272 AnalysisContext sdkContext = |
264 driver.context.sourceFactory.dartSdk.context; | 273 driver.context.sourceFactory.dartSdk.context; |
265 expect(sdkContext.analysisOptions.strongMode, isTrue); | 274 expect(sdkContext.analysisOptions.strongMode, isTrue); |
266 }); | 275 }); |
267 }); | 276 }); |
268 | 277 |
269 group('with flags - $designator', () { | 278 group('with flags - $designator', () { |
270 // Shared driver command. | 279 // Shared driver command. |
271 void doDrive() => drive('data/options_tests_project/test_file.dart', | 280 Future<Null> doDrive() async { |
272 args: ['--fatal-warnings'], | 281 await drive('data/options_tests_project/test_file.dart', |
273 options: 'data/options_tests_project/$optionsFileName'); | 282 args: ['--fatal-warnings'], |
| 283 options: 'data/options_tests_project/$optionsFileName'); |
| 284 } |
274 | 285 |
275 test('override fatal warning', () { | 286 test('override fatal warning', () async { |
276 doDrive(); | 287 await doDrive(); |
277 // missing_return: error | 288 // missing_return: error |
278 var undefined_function = new AnalysisError(new TestSource(), 0, 1, | 289 var undefined_function = new AnalysisError(new TestSource(), 0, 1, |
279 StaticTypeWarningCode.UNDEFINED_FUNCTION, [ | 290 StaticTypeWarningCode.UNDEFINED_FUNCTION, [ |
280 ['x'] | 291 ['x'] |
281 ]); | 292 ]); |
282 expect(processorFor(undefined_function).severity, | 293 expect(processorFor(undefined_function).severity, |
283 ErrorSeverity.WARNING); | 294 ErrorSeverity.WARNING); |
284 // Should not be made fatal by `--fatal-warnings`. | 295 // Should not be made fatal by `--fatal-warnings`. |
285 expect(outSink.toString(), | 296 expect(outSink.toString(), |
286 contains("[warning] The function 'baz' isn't defined")); | 297 contains("[warning] The function 'baz' isn't defined")); |
287 expect( | 298 expect( |
288 outSink.toString(), contains("1 error and 1 warning found.")); | 299 outSink.toString(), contains("1 error and 1 warning found.")); |
289 }); | 300 }); |
290 }); | 301 }); |
291 } | 302 } |
292 | 303 |
293 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); | 304 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); |
294 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 305 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
295 | 306 |
296 test('include directive', () { | 307 test('include directive', () async { |
297 String testDir = path.join( | 308 String testDir = path.join( |
298 testDirectory, 'data', 'options_include_directive_tests_project'); | 309 testDirectory, 'data', 'options_include_directive_tests_project'); |
299 drive( | 310 await drive( |
300 path.join(testDir, 'lib', 'test_file.dart'), | 311 path.join(testDir, 'lib', 'test_file.dart'), |
301 args: [ | 312 args: [ |
302 '--fatal-warnings', | 313 '--fatal-warnings', |
303 '--packages', | 314 '--packages', |
304 path.join(testDir, '_packages'), | 315 path.join(testDir, '_packages'), |
305 ], | 316 ], |
306 options: path.join(testDir, '.analysis_options'), | 317 options: path.join(testDir, '.analysis_options'), |
307 ); | 318 ); |
308 expect(exitCode, 3); | 319 expect(exitCode, 3); |
309 expect(outSink.toString(), | 320 expect(outSink.toString(), |
310 contains('but doesn\'t end with a return statement.')); | 321 contains('but doesn\'t end with a return statement.')); |
311 expect(outSink.toString(), contains('isn\'t defined')); | 322 expect(outSink.toString(), contains('isn\'t defined')); |
312 expect(outSink.toString(), contains('Avoid empty else statements.')); | 323 expect(outSink.toString(), contains('Avoid empty else statements.')); |
313 }); | 324 }); |
314 }); | 325 }); |
315 | 326 |
316 void createTests(String designator, String optionsFileName) { | 327 void createTests(String designator, String optionsFileName) { |
317 group('build-mode - $designator', () { | 328 group('build-mode - $designator', () { |
318 // Shared driver command. | 329 // Shared driver command. |
319 void doDrive(String filePath, {List<String> additionalArgs: const []}) { | 330 Future<Null> doDrive(String filePath, |
320 drive('file:///test_file.dart|$filePath', | 331 {List<String> additionalArgs: const []}) async { |
| 332 await drive('file:///test_file.dart|$filePath', |
321 args: [ | 333 args: [ |
322 '--dart-sdk', | 334 '--dart-sdk', |
323 findSdkDirForSummaries(), | 335 findSdkDirForSummaries(), |
324 '--build-mode', | 336 '--build-mode', |
325 '--machine' | 337 '--machine' |
326 ]..addAll(additionalArgs), | 338 ]..addAll(additionalArgs), |
327 options: 'data/options_tests_project/$optionsFileName'); | 339 options: 'data/options_tests_project/$optionsFileName'); |
328 } | 340 } |
329 | 341 |
330 test('no stats', () { | 342 test('no stats', () async { |
331 doDrive('data/test_file.dart'); | 343 await doDrive('data/test_file.dart'); |
332 // Should not print stat summary. | 344 // Should not print stat summary. |
333 expect(outSink.toString(), isEmpty); | 345 expect(outSink.toString(), isEmpty); |
334 expect(errorSink.toString(), isEmpty); | 346 expect(errorSink.toString(), isEmpty); |
335 expect(exitCode, 0); | 347 expect(exitCode, 0); |
336 }); | 348 }); |
337 | 349 |
338 test( | 350 test( |
339 'Fails if file not found, even when --build-suppress-exit-code is gi
ven', | 351 'Fails if file not found, even when --build-suppress-exit-code is gi
ven', |
340 () { | 352 () async { |
341 doDrive('data/non_existent_file.dart', | 353 await doDrive('data/non_existent_file.dart', |
342 additionalArgs: ['--build-suppress-exit-code']); | 354 additionalArgs: ['--build-suppress-exit-code']); |
343 expect(exitCode, isNot(0)); | 355 expect(exitCode, isNot(0)); |
344 }); | 356 }); |
345 | 357 |
346 test('Fails if there are errors', () { | 358 test('Fails if there are errors', () async { |
347 doDrive('data/file_with_error.dart'); | 359 await doDrive('data/file_with_error.dart'); |
348 expect(exitCode, isNot(0)); | 360 expect(exitCode, isNot(0)); |
349 }); | 361 }); |
350 | 362 |
351 test( | 363 test( |
352 'Succeeds if there are errors, when --build-suppress-exit-code is gi
ven', | 364 'Succeeds if there are errors, when --build-suppress-exit-code is gi
ven', |
353 () { | 365 () async { |
354 doDrive('data/file_with_error.dart', | 366 await doDrive('data/file_with_error.dart', |
355 additionalArgs: ['--build-suppress-exit-code']); | 367 additionalArgs: ['--build-suppress-exit-code']); |
356 expect(exitCode, 0); | 368 expect(exitCode, 0); |
357 }); | 369 }); |
358 }); | 370 }); |
359 } | 371 } |
360 | 372 |
361 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); | 373 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); |
362 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 374 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
363 | 375 |
364 //TODO(pq): fix to be bot-friendly (sdk#25258). | 376 //TODO(pq): fix to be bot-friendly (sdk#25258). |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 int uriPrefixLength = fileSpec.indexOf('|') + 1; | 451 int uriPrefixLength = fileSpec.indexOf('|') + 1; |
440 String uriPrefix = fileSpec.substring(0, uriPrefixLength); | 452 String uriPrefix = fileSpec.substring(0, uriPrefixLength); |
441 String relativePath = fileSpec.substring(uriPrefixLength); | 453 String relativePath = fileSpec.substring(uriPrefixLength); |
442 return '$uriPrefix${path.join(testDirectory, relativePath)}'; | 454 return '$uriPrefix${path.join(testDirectory, relativePath)}'; |
443 } | 455 } |
444 | 456 |
445 /// Start a driver for the given [source], optionally providing additional | 457 /// Start a driver for the given [source], optionally providing additional |
446 /// [args] and an [options] file path. The value of [options] defaults to | 458 /// [args] and an [options] file path. The value of [options] defaults to |
447 /// an empty options file to avoid unwanted configuration from an otherwise | 459 /// an empty options file to avoid unwanted configuration from an otherwise |
448 /// discovered options file. | 460 /// discovered options file. |
449 void drive(String source, | 461 Future<Null> drive(String source, |
450 {String options: emptyOptionsFile, List<String> args: const <String>[]}) { | 462 {String options: emptyOptionsFile, |
| 463 List<String> args: const <String>[]}) async { |
451 driver = new Driver(); | 464 driver = new Driver(); |
452 var cmd = [ | 465 var cmd = [ |
453 '--options', | 466 '--options', |
454 path.join(testDirectory, options), | 467 path.join(testDirectory, options), |
455 adjustFileSpec(source) | 468 adjustFileSpec(source) |
456 ]..addAll(args); | 469 ]..addAll(args); |
457 driver.start(cmd); | 470 await driver.start(cmd); |
458 } | 471 } |
459 | 472 |
460 /// Try to find a appropriate directory to pass to "--dart-sdk" that will | 473 /// Try to find a appropriate directory to pass to "--dart-sdk" that will |
461 /// allow summaries to be found. | 474 /// allow summaries to be found. |
462 String findSdkDirForSummaries() { | 475 String findSdkDirForSummaries() { |
463 Set<String> triedDirectories = new Set<String>(); | 476 Set<String> triedDirectories = new Set<String>(); |
464 bool isSuitable(String sdkDir) { | 477 bool isSuitable(String sdkDir) { |
465 triedDirectories.add(sdkDir); | 478 triedDirectories.add(sdkDir); |
466 return new File(path.join(sdkDir, 'lib', '_internal', 'spec.sum')) | 479 return new File(path.join(sdkDir, 'lib', '_internal', 'spec.sum')) |
467 .existsSync(); | 480 .existsSync(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 519 |
507 ErrorProcessor processorFor(AnalysisError error) => | 520 ErrorProcessor processorFor(AnalysisError error) => |
508 processors.firstWhere((p) => p.appliesTo(error)); | 521 processors.firstWhere((p) => p.appliesTo(error)); |
509 | 522 |
510 class TestSource implements Source { | 523 class TestSource implements Source { |
511 TestSource(); | 524 TestSource(); |
512 | 525 |
513 @override | 526 @override |
514 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 527 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
515 } | 528 } |
OLD | NEW |