| Index: lib/src/utils.dart
|
| diff --git a/lib/src/utils.dart b/lib/src/utils.dart
|
| index 6b2b21ef6c22f648490648009ec79d4ab2f70731..2a12238932ded4d1533bd5c9b34f3094e3012713 100644
|
| --- a/lib/src/utils.dart
|
| +++ b/lib/src/utils.dart
|
| @@ -6,8 +6,11 @@ library unittest.utils;
|
|
|
| import 'dart:async';
|
|
|
| +import 'package:path/path.dart' as p;
|
| import 'package:stack_trace/stack_trace.dart';
|
|
|
| +import 'backend/operating_system.dart';
|
| +
|
| /// A typedef for a possibly-asynchronous function.
|
| ///
|
| /// The return type should only ever by [Future] or void.
|
| @@ -17,6 +20,30 @@ typedef AsyncFunction();
|
| /// [Object.toString] values contain.
|
| final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
|
|
|
| +/// Directories that are specific to OS X.
|
| +///
|
| +/// This is used to try to distinguish OS X and Linux in [currentOsGuess].
|
| +final _macOsDirectories = new Set<String>.from([
|
| + "/Applications",
|
| + "/Library",
|
| + "/Network",
|
| + "/System",
|
| + "/Users"
|
| +]);
|
| +
|
| +/// Returns the best guess for the current operating system without using
|
| +/// `dart:io`.
|
| +///
|
| +/// This is useful for running test files directly and skipping tests as
|
| +/// appropriate. The only OS-specific information we have is the current path,
|
| +/// which we try to use to figure out the OS.
|
| +final OperatingSystem currentOsGuess = (() {
|
| + if (p.style == p.Style.url) return OperatingSystem.none;
|
| + if (p.style == p.Style.windows) return OperatingSystem.windows;
|
| + if (_macOsDirectories.any(p.current.startsWith)) return OperatingSystem.macOs;
|
| + return OperatingSystem.linux;
|
| +})();
|
| +
|
| /// Get a string description of an exception.
|
| ///
|
| /// Many exceptions include the exception class name at the beginning of their
|
|
|