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

Side by Side Diff: tools/testing/dart/utils.dart

Issue 2863253002: Tighten up a bunch of types in test.dart. (Closed)
Patch Set: Merge branch 'master' into types-for-test Created 3 years, 7 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 | « tools/testing/dart/test_suite.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 utils; 5 library utils;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'path.dart'; 10 import 'path.dart';
11 11
12 // This is the maximum time we expect stdout/stderr of subprocesses to deliver 12 // This is the maximum time we expect stdout/stderr of subprocesses to deliver
13 // data after we've got the exitCode. 13 // data after we've got the exitCode.
14 const Duration MAX_STDIO_DELAY = const Duration(seconds: 30); 14 const Duration MAX_STDIO_DELAY = const Duration(seconds: 30);
15 15
16 String MAX_STDIO_DELAY_PASSED_MESSAGE = 16 String MAX_STDIO_DELAY_PASSED_MESSAGE =
17 """Not waiting for stdout/stderr from subprocess anymore 17 """Not waiting for stdout/stderr from subprocess anymore
18 ($MAX_STDIO_DELAY passed). Please note that this could be an indicator 18 ($MAX_STDIO_DELAY passed). Please note that this could be an indicator
19 that there is a hanging process which we were unable to kill."""; 19 that there is a hanging process which we were unable to kill.""";
20 20
21 class DebugLogger { 21 class DebugLogger {
22 static IOSink _sink; 22 static IOSink _sink;
23 23
24 /** 24 /**
25 * If [path] was null, the DebugLogger will write messages to stdout. 25 * If [path] was null, the DebugLogger will write messages to stdout.
26 */ 26 */
27 static init(Path path, {append: false}) { 27 static void init(Path path, {bool append: false}) {
28 if (path != null) { 28 if (path != null) {
29 var mode = append ? FileMode.APPEND : FileMode.WRITE; 29 var mode = append ? FileMode.APPEND : FileMode.WRITE;
30 _sink = new File(path.toNativePath()).openWrite(mode: mode); 30 _sink = new File(path.toNativePath()).openWrite(mode: mode);
31 } 31 }
32 } 32 }
33 33
34 static void close() { 34 static void close() {
35 if (_sink != null) { 35 if (_sink != null) {
36 _sink.close(); 36 _sink.close();
37 _sink = null; 37 _sink = null;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 // TODO(kustermann,ricow): As soon we have a debug log we should log 174 // TODO(kustermann,ricow): As soon we have a debug log we should log
175 // invalid utf8-encoded input to the log. 175 // invalid utf8-encoded input to the log.
176 // Currently invalid bytes will be replaced by a replacement character. 176 // Currently invalid bytes will be replaced by a replacement character.
177 String decodeUtf8(List<int> bytes) { 177 String decodeUtf8(List<int> bytes) {
178 return UTF8.decode(bytes, allowMalformed: true); 178 return UTF8.decode(bytes, allowMalformed: true);
179 } 179 }
180 180
181 class Locations { 181 class Locations {
182 static String getBrowserLocation( 182 static String getBrowserLocation(
183 String browserName, Map globalConfiguration) { 183 String browserName, Map<String, String> globalConfiguration) {
184 var location = globalConfiguration[browserName]; 184 var location = globalConfiguration[browserName];
185 if (location != null && location != '') { 185 if (location != null && location != '') {
186 return location; 186 return location;
187 } 187 }
188 var browserLocations = { 188 var browserLocations = {
189 'firefox': const { 189 'firefox': const {
190 'windows': 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', 190 'windows': 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
191 'linux': 'firefox', 191 'linux': 'firefox',
192 'macos': '/Applications/Firefox.app/Contents/MacOS/firefox' 192 'macos': '/Applications/Firefox.app/Contents/MacOS/firefox'
193 }, 193 },
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 throw new Exception("Can't compare two non json-like objects " 299 throw new Exception("Can't compare two non json-like objects "
300 "(a: ${a.runtimeType}, b: ${b.runtimeType})"); 300 "(a: ${a.runtimeType}, b: ${b.runtimeType})");
301 } 301 }
302 } 302 }
303 303
304 class UniqueObject { 304 class UniqueObject {
305 static int _nextId = 1; 305 static int _nextId = 1;
306 final int _hashCode; 306 final int _hashCode;
307 307
308 int get hashCode => _hashCode; 308 int get hashCode => _hashCode;
309 operator ==(other) => other is UniqueObject && _hashCode == other._hashCode; 309 operator ==(Object other) =>
310 other is UniqueObject && _hashCode == other._hashCode;
310 311
311 UniqueObject() : _hashCode = ++_nextId; 312 UniqueObject() : _hashCode = ++_nextId;
312 } 313 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698