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

Side by Side Diff: lib/src/util/io.dart

Issue 1027193004: Respect top-level @TestOn declarations. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Add another test. 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 unified diff | Download patch
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 unittest.util.io; 5 library unittest.util.io;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
11 import 'package:path/path.dart' as p; 11 import 'package:path/path.dart' as p;
12 12
13 import '../backend/operating_system.dart';
13 import '../runner/load_exception.dart'; 14 import '../runner/load_exception.dart';
14 15
15 /// The root directory of the Dart SDK. 16 /// The root directory of the Dart SDK.
16 final String sdkDir = 17 final String sdkDir =
17 p.dirname(p.dirname(Platform.executable)); 18 p.dirname(p.dirname(Platform.executable));
18 19
20 /// Returns the current operating system.
21 final OperatingSystem currentOS = (() {
22 var name = Platform.operatingSystem;
23 var os = OperatingSystem.findByIoName(name);
24 if (os != null) return os;
25
26 throw new UnsupportedError('Unsupported operating system "$name".');
27 })();
28
19 /// The path to the `lib` directory of the `unittest` package. 29 /// The path to the `lib` directory of the `unittest` package.
20 String libDir({String packageRoot}) { 30 String libDir({String packageRoot}) {
21 var pathToIo = libraryPath(#unittest.util.io, packageRoot: packageRoot); 31 var pathToIo = libraryPath(#unittest.util.io, packageRoot: packageRoot);
22 return p.dirname(p.dirname(p.dirname(pathToIo))); 32 return p.dirname(p.dirname(p.dirname(pathToIo)));
23 } 33 }
24 34
25 /// Returns whether the current Dart version supports [Isolate.kill]. 35 /// Returns whether the current Dart version supports [Isolate.kill].
26 final bool supportsIsolateKill = _supportsIsolateKill; 36 final bool supportsIsolateKill = _supportsIsolateKill;
27 bool get _supportsIsolateKill { 37 bool get _supportsIsolateKill {
28 // This isn't 100% accurate, since early 1.9 dev releases didn't support 38 // This isn't 100% accurate, since early 1.9 dev releases didn't support
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 /// returned. 107 /// returned.
98 String libraryPath(Symbol libraryName, {String packageRoot}) { 108 String libraryPath(Symbol libraryName, {String packageRoot}) {
99 var lib = currentMirrorSystem().findLibrary(libraryName); 109 var lib = currentMirrorSystem().findLibrary(libraryName);
100 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); 110 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri);
101 111
102 // TODO(nweiz): is there a way to avoid assuming this is being run next to a 112 // TODO(nweiz): is there a way to avoid assuming this is being run next to a
103 // packages directory?. 113 // packages directory?.
104 if (packageRoot == null) packageRoot = p.absolute('packages'); 114 if (packageRoot == null) packageRoot = p.absolute('packages');
105 return p.join(packageRoot, p.fromUri(lib.uri.path)); 115 return p.join(packageRoot, p.fromUri(lib.uri.path));
106 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698