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

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

Issue 1720963003: Initial hermetic package analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 900747befb4b4d0b4d00ab79fbe35686f1a0a5e7..1c6aa76336b384813548bbbae79bc919f14a4c57 100644
--- a/pkg/analyzer_cli/test/options_test.dart
+++ b/pkg/analyzer_cli/test/options_test.dart
@@ -4,8 +4,12 @@
library analyzer_cli.test.options;
+import 'dart:io';
+
+import 'package:analyzer_cli/src/driver.dart';
import 'package:analyzer_cli/src/options.dart';
import 'package:args/args.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:unittest/unittest.dart';
main() {
@@ -26,7 +30,9 @@ main() {
expect(options.ignoreUnrecognizedFlags, isFalse);
expect(options.log, isFalse);
expect(options.machineFormat, isFalse);
+ expect(options.packageMode, isFalse);
expect(options.packageRootPath, isNull);
+ expect(options.packageSummaryInputs, isEmpty);
expect(options.shouldBatch, isFalse);
expect(options.showPackageWarnings, isFalse);
expect(options.showSdkWarnings, isFalse);
@@ -165,8 +171,8 @@ main() {
});
test('strong mode', () {
- CommandLineOptions options = CommandLineOptions
- .parse(['--strong', 'foo.dart']);
+ CommandLineOptions options =
+ CommandLineOptions.parse(['--strong', 'foo.dart']);
expect(options.strongMode, isTrue);
});
@@ -187,4 +193,85 @@ main() {
});
});
});
+ defineReflectiveTests(CommandLineOptionsTest);
+}
+
+@reflectiveTest
+class AbstractStatusTest {
+ 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;
+ }
+}
+
+@reflectiveTest
+class CommandLineOptionsTest extends AbstractStatusTest {
+ CommandLineOptions options;
+
+ test_packageMode() {
+ _parse(['--package-mode', '/path/to/pkg']);
+ expect(options.packageMode, isTrue);
+ print(options.packageSummaryInputs);
+ }
+
+ test_packageSummaryInput() {
+ _parse([
+ '--package-mode',
+ '--package-summary-input=aaa,/path/to/aaa.sum',
+ '--package-summary-input=long.package.bbb,/path/to/bbb.sum',
+ '/path/to/pkg'
+ ]);
+ expect(options.packageMode, isTrue);
+ Map<String, String> map = options.packageSummaryInputs;
+ expect(map, hasLength(2));
+ expect(map, containsPair('aaa', '/path/to/aaa.sum'));
+ expect(map, containsPair('long.package.bbb', '/path/to/bbb.sum'));
+ }
+
+ test_packageSummaryInput_noComma() {
+ _parse([
+ '--package-mode',
+ '--package-summary-input=noCommaInMapping',
+ '/path/to/pkg'
+ ]);
+ expect(lastExitHandlerCode, 15);
+ expect(errorStringBuffer.toString(), contains('--package-summary-input'));
+ expect(errorStringBuffer.toString(), contains('noCommaInMapping'));
+ }
+
+ test_packageSummaryOutput() {
+ _parse([
+ '--package-mode',
+ '--package-summary-output=/path/to/output.sum',
+ '/path/to/pkg'
+ ]);
+ expect(options.packageMode, isTrue);
+ expect(options.packageSummaryOutput, '/path/to/output.sum');
+ }
+
+ void _parse(List<String> args) {
+ options = CommandLineOptions.parse(args);
+ }
}
« pkg/analyzer_cli/lib/src/package_analyzer.dart ('K') | « pkg/analyzer_cli/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698