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

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

Issue 1868663002: Update worker mode to use the bazel protos directly instead of json (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: s/setInputBytes/addInputBytes Created 4 years, 8 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
« no previous file with comments | « pkg/analyzer_cli/test/message_grouper_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer_cli.test.utils; 5 library analyzer_cli.test.utils;
6 6
7 import 'dart:collection';
7 import 'dart:io'; 8 import 'dart:io';
8 import 'dart:mirrors'; 9 import 'dart:mirrors';
9 10
10 import 'package:analyzer/analyzer.dart'; 11 import 'package:analyzer/analyzer.dart';
11 import 'package:analyzer/src/generated/java_io.dart'; 12 import 'package:analyzer/src/generated/java_io.dart';
12 import 'package:path/path.dart' as pathos; 13 import 'package:path/path.dart' as pathos;
13 import 'package:path/path.dart' as path; 14 import 'package:path/path.dart' as path;
15 import 'package:typed_mock/typed_mock.dart';
14 import 'package:unittest/unittest.dart'; 16 import 'package:unittest/unittest.dart';
15 17
16 /// Gets the test directory in a way that works with 18 /// Gets the test directory in a way that works with
17 /// package:test and package:unittest. 19 /// package:test and package:unittest.
18 /// See <https://github.com/dart-lang/test/issues/110> for more info. 20 /// See <https://github.com/dart-lang/test/issues/110> for more info.
19 final String testDirectory = pathos.dirname( 21 final String testDirectory = pathos.dirname(
20 pathos.fromUri((reflectClass(_TestUtils).owner as LibraryMirror).uri)); 22 pathos.fromUri((reflectClass(_TestUtils).owner as LibraryMirror).uri));
21 23
22 /// Returns the string representation of the [AnalyzerErrorGroup] thrown when 24 /// Returns the string representation of the [AnalyzerErrorGroup] thrown when
23 /// parsing [contents] as a Dart file. If [contents] doesn't throw any errors, 25 /// parsing [contents] as a Dart file. If [contents] doesn't throw any errors,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 dynamic withTempDir(fn(String path)) { 58 dynamic withTempDir(fn(String path)) {
57 var tempDir = Directory.systemTemp.createTempSync('analyzer_').path; 59 var tempDir = Directory.systemTemp.createTempSync('analyzer_').path;
58 try { 60 try {
59 return fn(tempDir); 61 return fn(tempDir);
60 } finally { 62 } finally {
61 new Directory(tempDir).deleteSync(recursive: true); 63 new Directory(tempDir).deleteSync(recursive: true);
62 } 64 }
63 } 65 }
64 66
65 class _TestUtils {} 67 class _TestUtils {}
68
69 /**
70 * A [Stdin] mock.
71 */
72 class TestStdinStream extends TypedMock implements Stdin {
73 final pendingBytes = new Queue<int>();
74
75 // Adds all the input bytes to this stream.
76 void addInputBytes(List<int> bytes) {
77 pendingBytes.addAll(bytes);
78 }
79
80 @override
81 int readByteSync() {
82 if (pendingBytes.isEmpty) {
83 return -1;
84 } else {
85 return pendingBytes.removeFirst();
86 }
87 }
88 }
89
90 /**
91 * A [Stdout] mock.
92 */
93 class TestStdoutStream extends TypedMock implements Stdout {
94 final writes = <List<int>>[];
95
96 @override
97 void add(List<int> bytes) {
98 super.add(bytes);
99 writes.add(bytes);
100 }
101 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/test/message_grouper_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698