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

Unified Diff: pkg/analyzer_cli/test/options_test.dart

Issue 2963323002: Add analytics to analyzer-cli and analysis server. (Closed)
Patch Set: update from review comments Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer_cli/test/options_test.dart
diff --git a/pkg/analyzer_cli/test/options_test.dart b/pkg/analyzer_cli/test/options_test.dart
index e8a22ecc7de24da4a4ae6a7b721b3ba67a18c7d0..2a5b1758f571cd06d28b49303cf91d741456889c 100644
--- a/pkg/analyzer_cli/test/options_test.dart
+++ b/pkg/analyzer_cli/test/options_test.dart
@@ -9,11 +9,39 @@ import 'dart:io';
import 'package:analyzer_cli/src/driver.dart';
import 'package:analyzer_cli/src/options.dart';
import 'package:test/test.dart';
+import 'package:usage/usage.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
main() {
group('CommandLineOptions', () {
group('parse', () {
+ int lastExitHandlerCode;
+ StringBuffer outStringBuffer = new StringBuffer();
+ StringBuffer errorStringBuffer = new StringBuffer();
+
+ StringSink savedOutSink, savedErrorSink;
+ int savedExitCode;
+ ExitHandler savedExitHandler;
+
+ setUp(() {
+ savedOutSink = outSink;
+ savedErrorSink = errorSink;
+ savedExitHandler = exitHandler;
+ savedExitCode = exitCode;
+ exitHandler = (int code) {
+ lastExitHandlerCode = code;
+ };
+ outSink = outStringBuffer;
+ errorSink = errorStringBuffer;
+ });
+
+ tearDown(() {
+ outSink = savedOutSink;
+ errorSink = savedErrorSink;
+ exitCode = savedExitCode;
+ exitHandler = savedExitHandler;
+ });
+
test('defaults', () {
CommandLineOptions options =
CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']);
@@ -41,7 +69,7 @@ main() {
expect(options.log, isFalse);
expect(options.machineFormat, isFalse);
expect(options.packageRootPath, isNull);
- expect(options.shouldBatch, isFalse);
+ expect(options.batchMode, isFalse);
expect(options.showPackageWarnings, isFalse);
expect(options.showSdkWarnings, isFalse);
expect(options.sourceFiles, equals(['foo.dart']));
@@ -53,7 +81,7 @@ main() {
test('batch', () {
CommandLineOptions options =
CommandLineOptions.parse(['--dart-sdk', '.', '--batch']);
- expect(options.shouldBatch, isTrue);
+ expect(options.batchMode, isTrue);
});
test('defined variables', () {
@@ -195,17 +223,35 @@ main() {
var failureMessage;
CommandLineOptions.parse(
['--package-root', '.', '--packages', '.', 'foo.dart'],
- (msg) => failureMessage = msg);
+ printAndFail: (msg) => failureMessage = msg);
expect(failureMessage,
equals("Cannot specify both '--package-root' and '--packages."));
});
test("bad SDK dir", () {
var failureMessage;
- CommandLineOptions.parse(
- ['--dart-sdk', '&&&&&', 'foo.dart'], (msg) => failureMessage = msg);
+ CommandLineOptions.parse(['--dart-sdk', '&&&&&', 'foo.dart'],
+ printAndFail: (msg) => failureMessage = msg);
expect(failureMessage, equals('Invalid Dart SDK path: &&&&&'));
});
+
+ test('--analytics', () {
+ AnalyticsMock mock = new AnalyticsMock()..enabled = false;
+ setAnalytics(mock);
+ CommandLineOptions.parse(['--analytics']);
+ expect(mock.enabled, true);
+ expect(lastExitHandlerCode, 0);
+ expect(outStringBuffer.toString(), contains('Analytics are currently'));
+ });
+
+ test('--no-analytics', () {
+ AnalyticsMock mock = new AnalyticsMock()..enabled = false;
+ setAnalytics(mock);
+ CommandLineOptions.parse(['--no-analytics']);
+ expect(mock.enabled, false);
+ expect(lastExitHandlerCode, 0);
+ expect(outStringBuffer.toString(), contains('Analytics are currently'));
+ });
});
});
defineReflectiveTests(CommandLineOptionsTest);
« no previous file with comments | « pkg/analyzer_cli/test/errors_upgrade_fails_cli_test.dart ('k') | pkg/analyzer_cli/test/package_prefix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698