| 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 @TestOn("vm") | 5 @TestOn("vm") |
| 6 library analyzer_cli.test.options; | 6 library analyzer_cli.test.options; |
| 7 | 7 |
| 8 import 'package:analyzer_cli/src/options.dart'; | 8 import 'package:analyzer_cli/src/options.dart'; |
| 9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 group('CommandLineOptions', () { | 13 group('CommandLineOptions', () { |
| 14 group('parse', () { | 14 group('parse', () { |
| 15 test('defaults', () { | 15 test('defaults', () { |
| 16 CommandLineOptions options = | 16 CommandLineOptions options = |
| 17 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); | 17 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); |
| 18 expect(options, isNotNull); | 18 expect(options, isNotNull); |
| 19 expect(options.dartSdkPath, isNotNull); | 19 expect(options.dartSdkPath, isNotNull); |
| 20 expect(options.disableHints, isFalse); | 20 expect(options.disableHints, isFalse); |
| 21 expect(options.lints, isFalse); | 21 expect(options.lints, isFalse); |
| 22 expect(options.displayVersion, isFalse); | 22 expect(options.displayVersion, isFalse); |
| 23 expect(options.enableStrictCallChecks, isFalse); | 23 expect(options.enableStrictCallChecks, isFalse); |
| 24 expect(options.enableSuperMixins, isFalse); | 24 expect(options.enableSuperMixins, isFalse); |
| 25 expect(options.enableTypeChecks, isFalse); | 25 expect(options.enableTypeChecks, isFalse); |
| 26 expect(options.hintsAreFatal, isFalse); |
| 26 expect(options.ignoreUnrecognizedFlags, isFalse); | 27 expect(options.ignoreUnrecognizedFlags, isFalse); |
| 27 expect(options.log, isFalse); | 28 expect(options.log, isFalse); |
| 28 expect(options.machineFormat, isFalse); | 29 expect(options.machineFormat, isFalse); |
| 29 expect(options.packageRootPath, isNull); | 30 expect(options.packageRootPath, isNull); |
| 30 expect(options.shouldBatch, isFalse); | 31 expect(options.shouldBatch, isFalse); |
| 31 expect(options.showPackageWarnings, isFalse); | 32 expect(options.showPackageWarnings, isFalse); |
| 32 expect(options.showSdkWarnings, isFalse); | 33 expect(options.showSdkWarnings, isFalse); |
| 33 expect(options.sourceFiles, equals(['foo.dart'])); | 34 expect(options.sourceFiles, equals(['foo.dart'])); |
| 34 expect(options.warningsAreFatal, isFalse); | 35 expect(options.warningsAreFatal, isFalse); |
| 35 expect(options.strongMode, isFalse); | 36 expect(options.strongMode, isFalse); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 59 .parse(['--dart-sdk', '.', '--supermixin', 'foo.dart']); | 60 .parse(['--dart-sdk', '.', '--supermixin', 'foo.dart']); |
| 60 expect(options.enableSuperMixins, isTrue); | 61 expect(options.enableSuperMixins, isTrue); |
| 61 }); | 62 }); |
| 62 | 63 |
| 63 test('enable type checks', () { | 64 test('enable type checks', () { |
| 64 CommandLineOptions options = CommandLineOptions | 65 CommandLineOptions options = CommandLineOptions |
| 65 .parse(['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); | 66 .parse(['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); |
| 66 expect(options.enableTypeChecks, isTrue); | 67 expect(options.enableTypeChecks, isTrue); |
| 67 }); | 68 }); |
| 68 | 69 |
| 70 test('hintsAreFatal', () { |
| 71 CommandLineOptions options = CommandLineOptions |
| 72 .parse(['--dart-sdk', '.', '--fatal-hints', 'foo.dart']); |
| 73 expect(options.hintsAreFatal, isTrue); |
| 74 }); |
| 75 |
| 69 test('log', () { | 76 test('log', () { |
| 70 CommandLineOptions options = | 77 CommandLineOptions options = |
| 71 CommandLineOptions.parse(['--dart-sdk', '.', '--log', 'foo.dart']); | 78 CommandLineOptions.parse(['--dart-sdk', '.', '--log', 'foo.dart']); |
| 72 expect(options.log, isTrue); | 79 expect(options.log, isTrue); |
| 73 }); | 80 }); |
| 74 | 81 |
| 75 test('machine format', () { | 82 test('machine format', () { |
| 76 CommandLineOptions options = CommandLineOptions | 83 CommandLineOptions options = CommandLineOptions |
| 77 .parse(['--dart-sdk', '.', '--format=machine', 'foo.dart']); | 84 .parse(['--dart-sdk', '.', '--format=machine', 'foo.dart']); |
| 78 expect(options.machineFormat, isTrue); | 85 expect(options.machineFormat, isTrue); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 183 |
| 177 test("bad SDK dir", () { | 184 test("bad SDK dir", () { |
| 178 var failureMessage; | 185 var failureMessage; |
| 179 CommandLineOptions.parse( | 186 CommandLineOptions.parse( |
| 180 ['--dart-sdk', '&&&&&', 'foo.dart'], (msg) => failureMessage = msg); | 187 ['--dart-sdk', '&&&&&', 'foo.dart'], (msg) => failureMessage = msg); |
| 181 expect(failureMessage, equals('Invalid Dart SDK path: &&&&&')); | 188 expect(failureMessage, equals('Invalid Dart SDK path: &&&&&')); |
| 182 }); | 189 }); |
| 183 }); | 190 }); |
| 184 }); | 191 }); |
| 185 } | 192 } |
| OLD | NEW |