| 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.options; | 5 library analyzer_cli.test.options; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analyzer_cli/src/driver.dart'; | 9 import 'package:analyzer_cli/src/driver.dart'; |
| 10 import 'package:analyzer_cli/src/options.dart'; | 10 import 'package:analyzer_cli/src/options.dart'; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 }); | 147 }); |
| 148 | 148 |
| 149 test('warningsAreFatal', () { | 149 test('warningsAreFatal', () { |
| 150 CommandLineOptions options = CommandLineOptions | 150 CommandLineOptions options = CommandLineOptions |
| 151 .parse(['--dart-sdk', '.', '--fatal-warnings', 'foo.dart']); | 151 .parse(['--dart-sdk', '.', '--fatal-warnings', 'foo.dart']); |
| 152 expect(options.warningsAreFatal, isTrue); | 152 expect(options.warningsAreFatal, isTrue); |
| 153 }); | 153 }); |
| 154 | 154 |
| 155 test('notice unrecognized flags', () { | 155 test('notice unrecognized flags', () { |
| 156 expect( | 156 expect( |
| 157 () => new CommandLineParser() | 157 () => new CommandLineParser().parse(['--bar', '--baz', 'foo.dart']), |
| 158 .parse(['--bar', '--baz', 'foo.dart'], {}), | |
| 159 throwsA(new isInstanceOf<FormatException>())); | 158 throwsA(new isInstanceOf<FormatException>())); |
| 160 }); | 159 }); |
| 161 | 160 |
| 162 test('ignore unrecognized flags', () { | 161 test('ignore unrecognized flags', () { |
| 163 CommandLineOptions options = CommandLineOptions.parse([ | 162 CommandLineOptions options = CommandLineOptions.parse([ |
| 164 '--ignore-unrecognized-flags', | 163 '--ignore-unrecognized-flags', |
| 165 '--bar', | 164 '--bar', |
| 166 '--baz', | 165 '--baz', |
| 167 '--dart-sdk', | 166 '--dart-sdk', |
| 168 '.', | 167 '.', |
| 169 'foo.dart' | 168 'foo.dart' |
| 170 ]); | 169 ]); |
| 171 expect(options, isNotNull); | 170 expect(options, isNotNull); |
| 172 expect(options.sourceFiles, equals(['foo.dart'])); | 171 expect(options.sourceFiles, equals(['foo.dart'])); |
| 173 }); | 172 }); |
| 174 | 173 |
| 175 test('ignore unrecognized options', () { | 174 test('ignore unrecognized options', () { |
| 176 CommandLineParser parser = | 175 CommandLineParser parser = |
| 177 new CommandLineParser(alwaysIgnoreUnrecognized: true); | 176 new CommandLineParser(alwaysIgnoreUnrecognized: true); |
| 178 parser.addOption('optionA'); | 177 parser.addOption('optionA'); |
| 179 parser.addFlag('flagA'); | 178 parser.addFlag('flagA'); |
| 180 ArgResults argResults = | 179 ArgResults argResults = |
| 181 parser.parse(['--optionA=1', '--optionB=2', '--flagA'], {}); | 180 parser.parse(['--optionA=1', '--optionB=2', '--flagA']); |
| 182 expect(argResults['optionA'], '1'); | 181 expect(argResults['optionA'], '1'); |
| 183 expect(argResults['flagA'], isTrue); | 182 expect(argResults['flagA'], isTrue); |
| 184 }); | 183 }); |
| 185 | 184 |
| 186 test('strong mode', () { | 185 test('strong mode', () { |
| 187 CommandLineOptions options = | 186 CommandLineOptions options = |
| 188 CommandLineOptions.parse(['--strong', 'foo.dart']); | 187 CommandLineOptions.parse(['--strong', 'foo.dart']); |
| 189 expect(options.strongMode, isTrue); | 188 expect(options.strongMode, isTrue); |
| 190 }); | 189 }); |
| 191 | 190 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 'package:p/foo.dart|/path/to/p/lib/foo.dart' | 351 'package:p/foo.dart|/path/to/p/lib/foo.dart' |
| 353 ]); | 352 ]); |
| 354 expect(options.buildMode, isTrue); | 353 expect(options.buildMode, isTrue); |
| 355 expect(options.buildSuppressExitCode, isTrue); | 354 expect(options.buildSuppressExitCode, isTrue); |
| 356 } | 355 } |
| 357 | 356 |
| 358 void _parse(List<String> args) { | 357 void _parse(List<String> args) { |
| 359 options = CommandLineOptions.parse(args); | 358 options = CommandLineOptions.parse(args); |
| 360 } | 359 } |
| 361 } | 360 } |
| OLD | NEW |