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

Side by Side Diff: pkg/code_transformers/lib/src/dart_sdk.dart

Issue 203723006: Fixes how to lookup sdk dir to support tests deeper inside test/ folders. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/code_transformers/lib/tests.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 code_transformers.src.dart_sdk; 5 library code_transformers.src.dart_sdk;
6 6
7 import 'dart:convert' as convert; 7 import 'dart:convert' as convert;
8 import 'dart:io' show Directory, File, Platform, Process; 8 import 'dart:io' show File, Platform, Process;
9 import 'package:path/path.dart' as path; 9 import 'package:path/path.dart' as path;
10 10
11 11
12 /// Attempts to provide the current Dart SDK directory. 12 /// Attempts to provide the current Dart SDK directory.
13 /// 13 ///
14 /// This will return null if the SDK cannot be found 14 /// This will return null if the SDK cannot be found
15 /// 15 ///
16 /// Note that this may not be correct when executing outside of `pub`. 16 /// Note that this may not be correct when executing outside of `pub`.
17 String get dartSdkDirectory { 17 String get dartSdkDirectory {
18 18
(...skipping 21 matching lines...) Expand all
40 40
41 var parts = path.split(dartDir); 41 var parts = path.split(dartDir);
42 // If the dart executable is within the sdk dir then get the root. 42 // If the dart executable is within the sdk dir then get the root.
43 if (parts.contains('dart-sdk')) { 43 if (parts.contains('dart-sdk')) {
44 var dartSdkDir = path.joinAll(parts.take(parts.indexOf('dart-sdk') + 1)); 44 var dartSdkDir = path.joinAll(parts.take(parts.indexOf('dart-sdk') + 1));
45 if (isSdkDir(dartSdkDir)) return dartSdkDir; 45 if (isSdkDir(dartSdkDir)) return dartSdkDir;
46 } 46 }
47 47
48 return null; 48 return null;
49 } 49 }
50
51 /// Variant of [dartSdkDirectory] which includes additional cases only
52 /// typically encountered in Dart's testing environment.
53 String get testingDartSdkDirectory {
54 var sdkDir = dartSdkDirectory;
55 if (sdkDir == null) {
56 // If we cannot find the SDK dir, then assume this is being run from Dart's
57 // source directory and this script is the main script.
58 sdkDir = path.join(
59 path.dirname(path.fromUri(Platform.script)), '..', '..', '..', 'sdk');
60 }
61 return sdkDir;
62 }
OLDNEW
« no previous file with comments | « no previous file | pkg/code_transformers/lib/tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698