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

Unified Diff: lib/src/utils.dart

Issue 1036943002: Add a testOn parameter to test() and group(). (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « lib/src/runner/vm/isolate_test.dart ('k') | lib/unittest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « lib/src/runner/vm/isolate_test.dart ('k') | lib/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698