Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: pkg/analyzer_cli/test/options_test.dart

Issue 3003343002: fix two test failures in analyzer_cli/test/options_test.dart (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
11 import 'package:telemetry/telemetry.dart' as telemetry;
11 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart';
12 import 'package:usage/usage.dart'; 14 import 'package:usage/usage.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 15
15 main() { 16 main() {
16 group('CommandLineOptions', () { 17 group('CommandLineOptions', () {
17 group('parse', () { 18 group('parse', () {
18 int lastExitHandlerCode; 19 int lastExitHandlerCode;
19 StringBuffer outStringBuffer = new StringBuffer(); 20 StringBuffer outStringBuffer = new StringBuffer();
20 StringBuffer errorStringBuffer = new StringBuffer(); 21 StringBuffer errorStringBuffer = new StringBuffer();
21 22
22 StringSink savedOutSink, savedErrorSink; 23 StringSink savedOutSink, savedErrorSink;
23 int savedExitCode; 24 int savedExitCode;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 equals("Cannot specify both '--package-root' and '--packages.")); 228 equals("Cannot specify both '--package-root' and '--packages."));
228 }); 229 });
229 230
230 test("bad SDK dir", () { 231 test("bad SDK dir", () {
231 var failureMessage; 232 var failureMessage;
232 CommandLineOptions.parse(['--dart-sdk', '&&&&&', 'foo.dart'], 233 CommandLineOptions.parse(['--dart-sdk', '&&&&&', 'foo.dart'],
233 printAndFail: (msg) => failureMessage = msg); 234 printAndFail: (msg) => failureMessage = msg);
234 expect(failureMessage, equals('Invalid Dart SDK path: &&&&&')); 235 expect(failureMessage, equals('Invalid Dart SDK path: &&&&&'));
235 }); 236 });
236 237
237 test('--analytics', () { 238 if (telemetry.SHOW_ANALYTICS_UI) {
238 AnalyticsMock mock = new AnalyticsMock()..enabled = false; 239 test('--analytics', () {
239 setAnalytics(mock); 240 AnalyticsMock mock = new AnalyticsMock()..enabled = false;
240 CommandLineOptions.parse(['--analytics']); 241 setAnalytics(mock);
241 expect(mock.enabled, true); 242 CommandLineOptions.parse(['--analytics']);
242 expect(lastExitHandlerCode, 0); 243 expect(mock.enabled, true);
243 expect(outStringBuffer.toString(), contains('Analytics are currently')); 244 expect(lastExitHandlerCode, 0);
244 }); 245 expect(
246 outStringBuffer.toString(), contains('Analytics are currently'));
247 });
245 248
246 test('--no-analytics', () { 249 test('--no-analytics', () {
247 AnalyticsMock mock = new AnalyticsMock()..enabled = false; 250 AnalyticsMock mock = new AnalyticsMock()..enabled = false;
248 setAnalytics(mock); 251 setAnalytics(mock);
249 CommandLineOptions.parse(['--no-analytics']); 252 CommandLineOptions.parse(['--no-analytics']);
250 expect(mock.enabled, false); 253 expect(mock.enabled, false);
251 expect(lastExitHandlerCode, 0); 254 expect(lastExitHandlerCode, 0);
252 expect(outStringBuffer.toString(), contains('Analytics are currently')); 255 expect(
253 }); 256 outStringBuffer.toString(), contains('Analytics are currently'));
257 });
258 }
254 }); 259 });
255 }); 260 });
256 defineReflectiveTests(CommandLineOptionsTest); 261 defineReflectiveTests(CommandLineOptionsTest);
257 } 262 }
258 263
259 @reflectiveTest 264 @reflectiveTest
260 class AbstractStatusTest { 265 class AbstractStatusTest {
261 int lastExitHandlerCode; 266 int lastExitHandlerCode;
262 StringBuffer outStringBuffer = new StringBuffer(); 267 StringBuffer outStringBuffer = new StringBuffer();
263 StringBuffer errorStringBuffer = new StringBuffer(); 268 StringBuffer errorStringBuffer = new StringBuffer();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 'package:p/foo.dart|/path/to/p/lib/foo.dart' 411 'package:p/foo.dart|/path/to/p/lib/foo.dart'
407 ]); 412 ]);
408 expect(options.buildMode, isTrue); 413 expect(options.buildMode, isTrue);
409 expect(options.buildSuppressExitCode, isTrue); 414 expect(options.buildSuppressExitCode, isTrue);
410 } 415 }
411 416
412 void _parse(List<String> args) { 417 void _parse(List<String> args) {
413 options = CommandLineOptions.parse(args); 418 options = CommandLineOptions.parse(args);
414 } 419 }
415 } 420 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698