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

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

Issue 1631763007: CLI support for embedders (#25380). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:io';
6
7 import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink;
8 import 'package:path/path.dart' as path;
9 import 'package:unittest/unittest.dart';
10
11 import 'utils.dart';
12
13 main() {
14 group('_embedder.yaml', () {
15 StringSink savedOutSink, savedErrorSink;
16 int savedExitCode;
17
18 setUp(() {
19 savedOutSink = outSink;
20 savedErrorSink = errorSink;
21 savedExitCode = exitCode;
22 outSink = new StringBuffer();
23 errorSink = new StringBuffer();
24 });
25 tearDown(() {
26 outSink = savedOutSink;
27 errorSink = savedErrorSink;
28 exitCode = savedExitCode;
29 });
30
31 initializeTestEnvironment();
Brian Wilkerson 2016/01/26 19:12:33 Perhaps move outside the group?
pquitslund 2016/01/26 19:22:19 Done.
32
33 test('resolution', wrap(() {
34 var testDir = path.join(testDirectory, 'data', 'embedder_client');
35 new Driver().start([
36 '--packages',
37 path.join(testDir, '_packages'),
38 path.join(testDir, 'embedder_yaml_user.dart')
39 ]);
40
41 expect(exitCode, 0);
42 expect(outSink.toString(), contains('No issues found'));
43 }));
44 });
45 }
46
47 /// Wrap a function call to dump stdout and stderr in case of an exception.
48 Function wrap(Function f) {
49 return () {
50 try {
51 f();
52 } catch (e) {
53 if (outSink.toString().isNotEmpty) {
54 print('stdout:');
55 print(outSink);
56 }
57 if (errorSink.toString().isNotEmpty) {
58 print('stderr:');
59 print(errorSink);
60 }
61 throw e;
62 }
63 };
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698