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

Side by Side Diff: packages/intl/test/data_directory.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 /**
6 * A utility function for test and tools that compensates (at least for very
7 * simple cases) for file-dependent programs being run from different
8 * directories. The important cases are
9 * - running in the directory that contains the test itself, i.e.
10 * test/ or a sub-directory.
11 * - running in root of this package, which is where the editor and bots will
12 * run things by default
13 */
14 library data_directory;
15
16 import "dart:io";
17 import "package:path/path.dart" as path;
18
19 String get dataDirectory {
20 return path.join(intlDirectory, datesRelativeToIntl);
21 }
22
23 /// Returns whether [dir] is the root of the `intl` package. We validate that it
24 /// is by looking for a pubspec file with the entry `name: intl`.
25 bool _isIntlRoot(String dir) {
26 var file = new File(path.join(dir, 'pubspec.yaml'));
27 if (!file.existsSync()) return false;
28 return file.readAsStringSync().contains('name: intl\n');
29 }
30
31 String get intlDirectory {
32 var dir = path.fromUri(Platform.script);
33 var root = path.rootPrefix(dir);
34
35 while (dir != root) {
36 if (_isIntlRoot(dir)) return dir;
37 dir = path.dirname(dir);
38 }
39 throw new UnsupportedError(
40 'Cannot find the root directory of the `intl` package.');
41 }
42
43 String get datesRelativeToIntl => path.join('lib', 'src', 'data', 'dates');
OLDNEW
« no previous file with comments | « packages/intl/test/bidi_utils_test.dart ('k') | packages/intl/test/date_time_format_file_even_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698