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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 import 'dart:io' show exitCode;
2
3 import 'package:analyzer_cli/src/driver.dart' show Driver, outSink, errorSink;
4 import 'package:analyzer_cli/src/options.dart' show ExitHandler, exitHandler;
5 import 'package:unittest/unittest.dart';
6
7 main() {
8 group('--x-package-warnings-prefix', () {
9 _Runner runner;
10
11 setUp(() {
12 runner = new _Runner.setUp();
13 });
14
15 tearDown(() {
16 runner.tearDown();
17 runner = null;
18 });
19
20 test('shows only the hint whose package matches the prefix', () {
21 runner.run([
22 "--packages",
23 "test/data/package_prefix/packagelist",
24 "--x-package-warnings-prefix=f",
25 "test/data/package_prefix/main.dart"
26 ]);
27 expect(runner.stdout, contains('1 hint found'));
28 expect(runner.stdout, contains('Unused import'));
29 expect(runner.stdout, contains('package_prefix/pkg/foo/foo.dart'));
30 expect(runner.stdout, isNot(contains('bar.dart')));
31 });
32 });
33 }
34
35 class _Runner {
36 final _stdout = new StringBuffer();
37 final _stderr = new StringBuffer();
38
39 final StringSink _savedOutSink;
40 final StringSink _savedErrorSink;
41 final int _savedExitCode;
42 final ExitHandler _savedExitHandler;
43
44 _Runner.setUp()
45 : _savedOutSink = outSink,
46 _savedErrorSink = errorSink,
47 _savedExitHandler = exitHandler,
48 _savedExitCode = exitCode {
49 outSink = _stdout;
50 errorSink = _stderr;
51 }
52
53 void run(List<String> args) {
54 new Driver().start(args);
55 if (stderr.isNotEmpty) {
56 fail("Unexpected output to stderr:\n$stderr");
57 }
58 }
59
60 String get stdout => _stdout.toString();
61 String get stderr => _stderr.toString();
62
63 void tearDown() {
64 outSink = _savedOutSink;
65 errorSink = _savedErrorSink;
66 exitCode = _savedExitCode;
67 exitHandler = _savedExitHandler;
68 }
69 }
OLDNEW
« 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