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

Side by Side Diff: lib/src/utils.dart

Issue 1034303003: Consistently use "OS" rather than "Os" in identifiers. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 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 | « no previous file | lib/unittest.dart » ('j') | 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 unittest.utils; 5 library unittest.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
11 11
12 import 'backend/operating_system.dart'; 12 import 'backend/operating_system.dart';
13 13
14 /// A typedef for a possibly-asynchronous function. 14 /// A typedef for a possibly-asynchronous function.
15 /// 15 ///
16 /// The return type should only ever by [Future] or void. 16 /// The return type should only ever by [Future] or void.
17 typedef AsyncFunction(); 17 typedef AsyncFunction();
18 18
19 /// A regular expression to match the exception prefix that some exceptions' 19 /// A regular expression to match the exception prefix that some exceptions'
20 /// [Object.toString] values contain. 20 /// [Object.toString] values contain.
21 final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): '); 21 final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
22 22
23 /// Directories that are specific to OS X. 23 /// Directories that are specific to OS X.
24 /// 24 ///
25 /// This is used to try to distinguish OS X and Linux in [currentOsGuess]. 25 /// This is used to try to distinguish OS X and Linux in [currentOSGuess].
26 final _macOsDirectories = new Set<String>.from([ 26 final _macOSDirectories = new Set<String>.from([
27 "/Applications", 27 "/Applications",
28 "/Library", 28 "/Library",
29 "/Network", 29 "/Network",
30 "/System", 30 "/System",
31 "/Users" 31 "/Users"
32 ]); 32 ]);
33 33
34 /// Returns the best guess for the current operating system without using 34 /// Returns the best guess for the current operating system without using
35 /// `dart:io`. 35 /// `dart:io`.
36 /// 36 ///
37 /// This is useful for running test files directly and skipping tests as 37 /// This is useful for running test files directly and skipping tests as
38 /// appropriate. The only OS-specific information we have is the current path, 38 /// appropriate. The only OS-specific information we have is the current path,
39 /// which we try to use to figure out the OS. 39 /// which we try to use to figure out the OS.
40 final OperatingSystem currentOsGuess = (() { 40 final OperatingSystem currentOSGuess = (() {
41 if (p.style == p.Style.url) return OperatingSystem.none; 41 if (p.style == p.Style.url) return OperatingSystem.none;
42 if (p.style == p.Style.windows) return OperatingSystem.windows; 42 if (p.style == p.Style.windows) return OperatingSystem.windows;
43 if (_macOsDirectories.any(p.current.startsWith)) return OperatingSystem.macOs; 43 if (_macOSDirectories.any(p.current.startsWith)) return OperatingSystem.macOS;
44 return OperatingSystem.linux; 44 return OperatingSystem.linux;
45 })(); 45 })();
46 46
47 /// Get a string description of an exception. 47 /// Get a string description of an exception.
48 /// 48 ///
49 /// Many exceptions include the exception class name at the beginning of their 49 /// Many exceptions include the exception class name at the beginning of their
50 /// [toString], so we remove that if it exists. 50 /// [toString], so we remove that if it exists.
51 String getErrorMessage(error) => 51 String getErrorMessage(error) =>
52 error.toString().replaceFirst(_exceptionPrefix, ''); 52 error.toString().replaceFirst(_exceptionPrefix, '');
53 53
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // Otherwise truncate to return the trailing text, but attempt to start at 135 // Otherwise truncate to return the trailing text, but attempt to start at
136 // the beginning of a word. 136 // the beginning of a word.
137 var result = text.substring(text.length - maxLength + 4); 137 var result = text.substring(text.length - maxLength + 4);
138 var firstSpace = result.indexOf(' '); 138 var firstSpace = result.indexOf(' ');
139 if (firstSpace > 0) { 139 if (firstSpace > 0) {
140 result = result.substring(firstSpace); 140 result = result.substring(firstSpace);
141 } 141 }
142 return '...$result'; 142 return '...$result';
143 } 143 }
OLDNEW
« no previous file with comments | « no previous file | lib/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698