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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer_cli/test/embedder_test.dart
diff --git a/pkg/analyzer_cli/test/embedder_test.dart b/pkg/analyzer_cli/test/embedder_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9fa4671ccdfc87a216e4cdb196f15b46ed65f491
--- /dev/null
+++ b/pkg/analyzer_cli/test/embedder_test.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+
+import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink;
+import 'package:path/path.dart' as path;
+import 'package:unittest/unittest.dart';
+
+import 'utils.dart';
+
+main() {
+ group('_embedder.yaml', () {
+ StringSink savedOutSink, savedErrorSink;
+ int savedExitCode;
+
+ setUp(() {
+ savedOutSink = outSink;
+ savedErrorSink = errorSink;
+ savedExitCode = exitCode;
+ outSink = new StringBuffer();
+ errorSink = new StringBuffer();
+ });
+ tearDown(() {
+ outSink = savedOutSink;
+ errorSink = savedErrorSink;
+ exitCode = savedExitCode;
+ });
+
+ initializeTestEnvironment();
Brian Wilkerson 2016/01/26 19:12:33 Perhaps move outside the group?
pquitslund 2016/01/26 19:22:19 Done.
+
+ test('resolution', wrap(() {
+ var testDir = path.join(testDirectory, 'data', 'embedder_client');
+ new Driver().start([
+ '--packages',
+ path.join(testDir, '_packages'),
+ path.join(testDir, 'embedder_yaml_user.dart')
+ ]);
+
+ expect(exitCode, 0);
+ expect(outSink.toString(), contains('No issues found'));
+ }));
+ });
+}
+
+/// Wrap a function call to dump stdout and stderr in case of an exception.
+Function wrap(Function f) {
+ return () {
+ try {
+ f();
+ } catch (e) {
+ if (outSink.toString().isNotEmpty) {
+ print('stdout:');
+ print(outSink);
+ }
+ if (errorSink.toString().isNotEmpty) {
+ print('stderr:');
+ print(errorSink);
+ }
+ throw e;
+ }
+ };
+}

Powered by Google App Engine
This is Rietveld 408576698