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

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

Issue 1806263004: add --x-package-warnings-prefix option to dartanalyzer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: oops, check in all the test files Created 4 years, 9 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/package_prefix_test.dart
diff --git a/pkg/analyzer_cli/test/package_prefix_test.dart b/pkg/analyzer_cli/test/package_prefix_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..23ff67f2c91b6d7aed6bb8bb86b0cd23433fdd26
--- /dev/null
+++ b/pkg/analyzer_cli/test/package_prefix_test.dart
@@ -0,0 +1,69 @@
+import 'dart:io' show exitCode;
+
+import 'package:analyzer_cli/src/driver.dart' show Driver, outSink, errorSink;
+import 'package:analyzer_cli/src/options.dart' show ExitHandler, exitHandler;
+import 'package:unittest/unittest.dart';
+
+main() {
+ group('--x-package-warnings-prefix', () {
+ _Runner runner;
+
+ setUp(() {
+ runner = new _Runner.setUp();
+ });
+
+ tearDown(() {
+ runner.tearDown();
+ runner = null;
+ });
+
+ test('shows only the hint whose package matches the prefix', () {
+ runner.run([
+ "--packages",
+ "test/data/package_prefix/packagelist",
+ "--x-package-warnings-prefix=f",
+ "test/data/package_prefix/main.dart"
+ ]);
+ expect(runner.stdout, contains('1 hint found'));
+ expect(runner.stdout, contains('Unused import'));
+ expect(runner.stdout, contains('package_prefix/pkg/foo/foo.dart'));
+ expect(runner.stdout, isNot(contains('bar.dart')));
+ });
+ });
+}
+
+class _Runner {
+ final _stdout = new StringBuffer();
+ final _stderr = new StringBuffer();
+
+ final StringSink _savedOutSink;
+ final StringSink _savedErrorSink;
+ final int _savedExitCode;
+ final ExitHandler _savedExitHandler;
+
+ _Runner.setUp()
+ : _savedOutSink = outSink,
+ _savedErrorSink = errorSink,
+ _savedExitHandler = exitHandler,
+ _savedExitCode = exitCode {
+ outSink = _stdout;
+ errorSink = _stderr;
+ }
+
+ void run(List<String> args) {
+ new Driver().start(args);
+ if (stderr.isNotEmpty) {
+ fail("Unexpected output to stderr:\n$stderr");
+ }
+ }
+
+ String get stdout => _stdout.toString();
+ String get stderr => _stderr.toString();
+
+ void tearDown() {
+ outSink = _savedOutSink;
+ errorSink = _savedErrorSink;
+ exitCode = _savedExitCode;
+ exitHandler = _savedExitHandler;
+ }
+}
« no previous file with comments | « pkg/analyzer_cli/test/data/package_prefix/pkg/foo/foo.dart ('k') | pkg/analyzer_cli/test/perf_report_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698