| 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:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
| 11 import 'package:analyzer/source/analysis_options_provider.dart'; | 11 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 12 import 'package:analyzer/source/error_processor.dart'; | 12 import 'package:analyzer/source/error_processor.dart'; |
| 13 import 'package:analyzer/src/error/codes.dart'; | 13 import 'package:analyzer/src/error/codes.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:analyzer/src/services/lint.dart'; | 16 import 'package:analyzer/src/services/lint.dart'; |
| 17 import 'package:analyzer/src/summary/idl.dart'; |
| 17 import 'package:analyzer_cli/src/ansi.dart' as ansi; | 18 import 'package:analyzer_cli/src/ansi.dart' as ansi; |
| 18 import 'package:analyzer_cli/src/driver.dart'; | 19 import 'package:analyzer_cli/src/driver.dart'; |
| 19 import 'package:analyzer_cli/src/options.dart'; | 20 import 'package:analyzer_cli/src/options.dart'; |
| 20 import 'package:cli_util/cli_util.dart' show getSdkDir; | 21 import 'package:cli_util/cli_util.dart' show getSdkDir; |
| 21 import 'package:path/path.dart' as path; | 22 import 'package:path/path.dart' as path; |
| 22 import 'package:test/test.dart'; | 23 import 'package:test/test.dart'; |
| 23 import 'package:yaml/src/yaml_node.dart'; | 24 import 'package:yaml/src/yaml_node.dart'; |
| 24 | 25 |
| 25 import 'utils.dart'; | 26 import 'utils.dart'; |
| 26 | 27 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 expect(exitCode, isNot(0)); | 406 expect(exitCode, isNot(0)); |
| 406 }); | 407 }); |
| 407 | 408 |
| 408 test( | 409 test( |
| 409 'Succeeds if there are errors, when --build-suppress-exit-code is gi
ven', | 410 'Succeeds if there are errors, when --build-suppress-exit-code is gi
ven', |
| 410 () async { | 411 () async { |
| 411 await doDrive(path.join('data', 'file_with_error.dart'), | 412 await doDrive(path.join('data', 'file_with_error.dart'), |
| 412 additionalArgs: ['--build-suppress-exit-code']); | 413 additionalArgs: ['--build-suppress-exit-code']); |
| 413 expect(exitCode, 0); | 414 expect(exitCode, 0); |
| 414 }); | 415 }); |
| 416 |
| 417 test('Linked summary', () async { |
| 418 await withTempDirAsync((tempDir) async { |
| 419 var outputPath = path.join(tempDir, 'test_file.dart.sum'); |
| 420 await doDrive(path.join('data', 'test_file.dart'), additionalArgs: [ |
| 421 '--build-summary-only', |
| 422 '--build-summary-output=$outputPath' |
| 423 ]); |
| 424 var output = new File(outputPath); |
| 425 expect(output.existsSync(), isTrue); |
| 426 PackageBundle bundle = |
| 427 new PackageBundle.fromBuffer(await output.readAsBytes()); |
| 428 var testFileUri = 'file:///test_file.dart'; |
| 429 expect(bundle.unlinkedUnitUris, equals([testFileUri])); |
| 430 expect(bundle.linkedLibraryUris, equals([testFileUri])); |
| 431 expect(exitCode, 0); |
| 432 }); |
| 433 }); |
| 434 |
| 435 test('Unlinked summary only', () async { |
| 436 await withTempDirAsync((tempDir) async { |
| 437 var outputPath = path.join(tempDir, 'test_file.dart.sum'); |
| 438 await doDrive(path.join('data', 'test_file.dart'), additionalArgs: [ |
| 439 '--build-summary-only', |
| 440 '--build-summary-only-unlinked', |
| 441 '--build-summary-output=$outputPath' |
| 442 ]); |
| 443 var output = new File(outputPath); |
| 444 expect(output.existsSync(), isTrue); |
| 445 PackageBundle bundle = |
| 446 new PackageBundle.fromBuffer(await output.readAsBytes()); |
| 447 var testFileUri = 'file:///test_file.dart'; |
| 448 expect(bundle.unlinkedUnits.length, 1); |
| 449 expect(bundle.unlinkedUnitUris, equals([testFileUri])); |
| 450 expect(bundle.linkedLibraryUris, isEmpty); |
| 451 expect(exitCode, 0); |
| 452 }); |
| 453 }); |
| 415 }); | 454 }); |
| 416 } | 455 } |
| 417 | 456 |
| 418 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); | 457 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); |
| 419 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 458 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
| 420 | 459 |
| 421 //TODO(pq): fix to be bot-friendly (sdk#25258). | 460 //TODO(pq): fix to be bot-friendly (sdk#25258). |
| 422 // group('in temp directory', () { | 461 // group('in temp directory', () { |
| 423 // Directory savedCurrentDirectory; | 462 // Directory savedCurrentDirectory; |
| 424 // Directory tempDir; | 463 // Directory tempDir; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 606 |
| 568 class TestSource implements Source { | 607 class TestSource implements Source { |
| 569 TestSource(); | 608 TestSource(); |
| 570 | 609 |
| 571 @override | 610 @override |
| 572 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 611 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 573 } | 612 } |
| 574 | 613 |
| 575 /// Normalize text with bullets. | 614 /// Normalize text with bullets. |
| 576 String _bulletToDash(item) => '$item'.replaceAll('•', '-'); | 615 String _bulletToDash(item) => '$item'.replaceAll('•', '-'); |
| OLD | NEW |