| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 expect(unusedLocalVariable.severity, isNull); | 249 expect(unusedLocalVariable.severity, isNull); |
| 250 }); | 250 }); |
| 251 | 251 |
| 252 test('language config', () { | 252 test('language config', () { |
| 253 doDrive(); | 253 doDrive(); |
| 254 expect(driver.context.analysisOptions.enableSuperMixins, isTrue); | 254 expect(driver.context.analysisOptions.enableSuperMixins, isTrue); |
| 255 }); | 255 }); |
| 256 }); | 256 }); |
| 257 }); | 257 }); |
| 258 | 258 |
| 259 group('in temp directory', () { | 259 //TODO(pq): fix to be bot-friendly (sdk#25258). |
| 260 Directory savedCurrentDirectory; | 260 // group('in temp directory', () { |
| 261 Directory tempDir; | 261 // Directory savedCurrentDirectory; |
| 262 setUp(() { | 262 // Directory tempDir; |
| 263 // Call base setUp. | 263 // setUp(() { |
| 264 _setUp(); | 264 // // Call base setUp. |
| 265 savedCurrentDirectory = Directory.current; | 265 // _setUp(); |
| 266 tempDir = Directory.systemTemp.createTempSync('analyzer_'); | 266 // savedCurrentDirectory = Directory.current; |
| 267 }); | 267 // tempDir = Directory.systemTemp.createTempSync('analyzer_'); |
| 268 tearDown(() { | 268 // }); |
| 269 Directory.current = savedCurrentDirectory; | 269 // tearDown(() { |
| 270 tempDir.deleteSync(recursive: true); | 270 // Directory.current = savedCurrentDirectory; |
| 271 // Call base tearDown. | 271 // tempDir.deleteSync(recursive: true); |
| 272 _tearDown(); | 272 // // Call base tearDown. |
| 273 }); | 273 // _tearDown(); |
| 274 // }); |
| 275 // |
| 276 // test('packages folder', () { |
| 277 // Directory.current = tempDir; |
| 278 // new File(path.join(tempDir.path, 'test.dart')).writeAsStringSync(''' |
| 279 //import 'package:foo/bar.dart'; |
| 280 //main() { |
| 281 // baz(); |
| 282 //} |
| 283 // '''); |
| 284 // Directory packagesDir = |
| 285 // new Directory(path.join(tempDir.path, 'packages')); |
| 286 // packagesDir.createSync(); |
| 287 // Directory fooDir = new Directory(path.join(packagesDir.path, 'foo')); |
| 288 // fooDir.createSync(); |
| 289 // new File(path.join(fooDir.path, 'bar.dart')).writeAsStringSync(''' |
| 290 //void baz() {} |
| 291 // '''); |
| 292 // new Driver().start(['test.dart']); |
| 293 // expect(exitCode, 0); |
| 294 // }); |
| 295 // |
| 296 // test('no package resolution', () { |
| 297 // Directory.current = tempDir; |
| 298 // new File(path.join(tempDir.path, 'test.dart')).writeAsStringSync(''' |
| 299 //import 'package:path/path.dart'; |
| 300 //main() {} |
| 301 // '''); |
| 302 // new Driver().start(['test.dart']); |
| 303 // expect(exitCode, 3); |
| 304 // String stdout = outSink.toString(); |
| 305 // expect(stdout, contains('[error] Target of URI does not exist')); |
| 306 // expect(stdout, contains('1 error found.')); |
| 307 // expect(errorSink.toString(), ''); |
| 308 // }); |
| 309 // |
| 310 // test('bad package root', () { |
| 311 // new Driver().start(['--package-root', 'does/not/exist', 'test.dart']); |
| 312 // String stdout = outSink.toString(); |
| 313 // expect(exitCode, 3); |
| 314 // expect( |
| 315 // stdout, |
| 316 // contains( |
| 317 // 'Package root directory (does/not/exist) does not exist.')); |
| 318 // }); |
| 319 // }); |
| 320 }); |
| 274 | 321 |
| 275 test('packages folder', () { | |
| 276 Directory.current = tempDir; | |
| 277 new File(path.join(tempDir.path, 'test.dart')).writeAsStringSync(''' | |
| 278 import 'package:foo/bar.dart'; | |
| 279 main() { | |
| 280 baz(); | |
| 281 } | |
| 282 '''); | |
| 283 Directory packagesDir = | |
| 284 new Directory(path.join(tempDir.path, 'packages')); | |
| 285 packagesDir.createSync(); | |
| 286 Directory fooDir = new Directory(path.join(packagesDir.path, 'foo')); | |
| 287 fooDir.createSync(); | |
| 288 new File(path.join(fooDir.path, 'bar.dart')).writeAsStringSync(''' | |
| 289 void baz() {} | |
| 290 '''); | |
| 291 new Driver().start(['test.dart']); | |
| 292 expect(exitCode, 0); | |
| 293 }); | |
| 294 | |
| 295 test('no package resolution', () { | |
| 296 Directory.current = tempDir; | |
| 297 new File(path.join(tempDir.path, 'test.dart')).writeAsStringSync(''' | |
| 298 import 'package:path/path.dart'; | |
| 299 main() {} | |
| 300 '''); | |
| 301 new Driver().start(['test.dart']); | |
| 302 expect(exitCode, 3); | |
| 303 String stdout = outSink.toString(); | |
| 304 expect(stdout, contains('[error] Target of URI does not exist')); | |
| 305 expect(stdout, contains('1 error found.')); | |
| 306 expect(errorSink.toString(), ''); | |
| 307 }); | |
| 308 | |
| 309 test('bad package root', () { | |
| 310 new Driver().start(['--package-root', 'does/not/exist', 'test.dart']); | |
| 311 String stdout = outSink.toString(); | |
| 312 expect(exitCode, 3); | |
| 313 expect( | |
| 314 stdout, | |
| 315 contains( | |
| 316 'Package root directory (does/not/exist) does not exist.')); | |
| 317 }); | |
| 318 }); | |
| 319 }); | |
| 320 group('Bootloader', () { | 322 group('Bootloader', () { |
| 321 group('plugin processing', () { | 323 group('plugin processing', () { |
| 322 test('bad format', () { | 324 test('bad format', () { |
| 323 BootLoader loader = new BootLoader(); | 325 BootLoader loader = new BootLoader(); |
| 324 loader.createImage([ | 326 loader.createImage([ |
| 325 '--options', | 327 '--options', |
| 326 path.join(testDirectory, 'data/bad_plugin_options.yaml'), | 328 path.join(testDirectory, 'data/bad_plugin_options.yaml'), |
| 327 path.join(testDirectory, 'data/test_file.dart') | 329 path.join(testDirectory, 'data/test_file.dart') |
| 328 ]); | 330 ]); |
| 329 expect( | 331 expect( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 this.options = options; | 427 this.options = options; |
| 426 } | 428 } |
| 427 } | 429 } |
| 428 | 430 |
| 429 class TestSource implements Source { | 431 class TestSource implements Source { |
| 430 TestSource(); | 432 TestSource(); |
| 431 | 433 |
| 432 @override | 434 @override |
| 433 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 435 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 434 } | 436 } |
| OLD | NEW |