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

Side by Side Diff: tools/migration/lib/src/test_directories.dart

Issue 2989033002: Migrate status file entries when migrating files. Yay! (Closed)
Patch Set: Remove old TODO. Created 3 years, 4 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
« no previous file with comments | « tools/migration/lib/src/migrate_statuses.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, 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 /// Manages the directories where tests can appear and the relationships
6 /// between them.
7
8 import 'package:path/path.dart' as p;
9
10 const oneRootDirs = const [
11 "corelib",
12 "html",
13 "isolate",
14 "language",
15 "lib",
16 ];
17
18 const strongRootDirs = const [
19 "corelib_strong",
20 "language_strong",
21 "lib_strong",
22 ];
23
24 const twoRootDirs = const [
25 "corelib_2",
26 "language_2",
27 "lib_2",
28 ];
29
30 final fromRootDirs = oneRootDirs.toList()..addAll(strongRootDirs);
31
32 // Note: The order is significant. "html" and "isolate" need to come first so
33 // that they don't get handled by the general "lib" directory.
34 final _directories = [
35 new _Directory("corelib", "corelib_strong", "corelib_2"),
36 new _Directory("html", p.join("lib_strong", "html"), p.join("lib_2", "html")),
37 new _Directory(
38 "isolate", p.join("lib_strong", "isolate"), p.join("lib_2", "isolate")),
39 new _Directory("language", "language_strong", "language_2"),
40 new _Directory("lib", "lib_strong", "lib_2"),
41 ];
42
43 /// Maps a Dart 1.0 or DDC root directory to its resulting migration Dart 2.0
44 /// directory.
45 String toTwoDirectory(String fromDir) {
46 for (var dir in _directories) {
47 if (dir.one == fromDir || dir.strong == fromDir) return dir.two;
48 }
49
50 throw new ArgumentError.value(fromDir, "fromDir");
51 }
52
53 /// Given a path within a Dart 1.0 or strong mode directory, returns the
54 /// corresponding Dart 2.0 path.
55 String toTwoPath(String fromPath) {
56 for (var dir in _directories) {
57 if (p.isWithin(dir.one, fromPath)) {
58 var relative = p.relative(fromPath, from: dir.one);
59 return p.join(dir.two, relative);
60 }
61
62 if (p.isWithin(dir.strong, fromPath)) {
63 var relative = p.relative(fromPath, from: dir.strong);
64 return p.join(dir.two, relative);
65 }
66 }
67
68 throw new ArgumentError.value(fromPath, "fromPath");
69 }
70
71 /// Given a path within a Dart 2.0 directory, returns the corresponding Dart 1.0
72 /// path.
73 String toOnePath(String twoPath) {
74 for (var dir in _directories) {
75 if (p.isWithin(dir.two, twoPath)) {
76 var relative = p.relative(twoPath, from: dir.two);
77 return p.join(dir.one, relative);
78 }
79 }
80
81 throw new ArgumentError.value(twoPath, "twoPath");
82 }
83
84 /// Given a path within a Dart 2.0 directory, returns the corresponding DDC
85 /// strong mode.
86 String toStrongPath(String twoPath) {
87 for (var dir in _directories) {
88 if (p.isWithin(dir.two, twoPath)) {
89 var relative = p.relative(twoPath, from: dir.two);
90 return p.join(dir.strong, relative);
91 }
92 }
93
94 throw new ArgumentError.value(twoPath, "twoPath");
95 }
96
97 class _Directory {
98 final String one;
99 final String strong;
100 final String two;
101
102 _Directory(this.one, this.strong, this.two);
103 }
OLDNEW
« no previous file with comments | « tools/migration/lib/src/migrate_statuses.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698