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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/dependency_computer/cycle_test.dart

Issue 896623005: Use native async/await support in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 10 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library pub_tests;
6
7 import '../descriptor.dart' as d;
8 import '../test_pub.dart';
9 import 'utils.dart';
10
11 void main() {
12 initConfig();
13
14 integration(
15 "allows a package dependency cycle that's unrelated to " "transformers",
16 () {
17 d.dir(appPath, [d.pubspec({
18 "name": "myapp",
19 "dependencies": {
20 "foo": {
21 "path": "../foo"
22 }
23 },
24 "transformers": ["myapp/first", "myapp/second"]
25 }),
26 d.dir(
27 'lib',
28 [
29 d.file("first.dart", transformer()),
30 d.file("second.dart", transformer())])]).create();
31
32 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: {
33 "bar": {
34 "path": "../bar"
35 }
36 })]).create();
37
38 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: {
39 "baz": {
40 "path": "../baz"
41 }
42 })]).create();
43
44 d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: {
45 "foo": {
46 "path": "../foo"
47 }
48 })]).create();
49
50 expectDependencies({
51 'myapp/first': [],
52 'myapp/second': ['myapp/first']
53 });
54 });
55
56 integration(
57 "disallows a package dependency cycle that may be related to " "transforme rs",
58 () {
59 // Two layers of myapp transformers are necessary here because otherwise pub
60 // will figure out that the transformer doesn't import "foo" and thus
61 // doesn't transitively import itself. Import loops are tested below.
62 d.dir(appPath, [d.pubspec({
63 "name": "myapp",
64 "dependencies": {
65 "foo": {
66 "path": "../foo"
67 }
68 },
69 "transformers": ["myapp/first", "myapp/second"]
70 }),
71 d.dir(
72 'lib',
73 [
74 d.file("first.dart", transformer()),
75 d.file("second.dart", transformer())])]).create();
76
77 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: {
78 "bar": {
79 "path": "../bar"
80 }
81 })]).create();
82
83 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: {
84 "myapp": {
85 "path": "../myapp"
86 }
87 })]).create();
88
89 expectCycleException(
90 [
91 "myapp is transformed by myapp/second",
92 "myapp depends on foo",
93 "foo depends on bar",
94 "bar depends on myapp",
95 "myapp is transformed by myapp/first"]);
96 });
97
98 integration("disallows a transformation dependency cycle", () {
99 d.dir(appPath, [d.pubspec({
100 "name": "myapp",
101 "dependencies": {
102 "foo": {
103 "path": "../foo"
104 }
105 },
106 "transformers": ["foo"]
107 }), d.dir('lib', [d.file("myapp.dart", transformer())])]).create();
108
109 d.dir("foo", [d.pubspec({
110 "name": "foo",
111 "dependencies": {
112 "bar": {
113 "path": "../bar"
114 }
115 },
116 "transformers": ["bar"]
117 }), d.dir('lib', [d.file("foo.dart", transformer())])]).create();
118
119 d.dir("bar", [d.pubspec({
120 "name": "bar",
121 "dependencies": {
122 "myapp": {
123 "path": "../myapp"
124 }
125 },
126 "transformers": ["myapp"]
127 }), d.dir('lib', [d.file("bar.dart", transformer())])]).create();
128
129 expectCycleException(
130 [
131 "bar is transformed by myapp",
132 "myapp is transformed by foo",
133 "foo is transformed by bar"]);
134 });
135
136 integration(
137 "allows a cross-package import cycle that's unrelated to " "transformers",
138 () {
139 d.dir(appPath, [d.pubspec({
140 "name": "myapp",
141 "dependencies": {
142 "foo": {
143 "path": "../foo"
144 }
145 },
146 "transformers": ["myapp"]
147 }),
148 d.dir(
149 'lib',
150 [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).c reate();
151
152 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: {
153 "bar": {
154 "path": "../bar"
155 }
156 }),
157 d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])]) .create();
158
159 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: {
160 "baz": {
161 "path": "../baz"
162 }
163 }),
164 d.dir('lib', [d.file("bar.dart", "import 'package:baz/baz.dart';")])]) .create();
165
166 d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: {
167 "foo": {
168 "path": "../foo"
169 }
170 }),
171 d.dir('lib', [d.file("baz.dart", "import 'package:foo/foo.dart';")])]) .create();
172
173 expectDependencies({
174 'myapp': []
175 });
176 });
177
178 integration(
179 "disallows a cross-package import cycle that's related to " "transformers" ,
180 () {
181 d.dir(appPath, [d.pubspec({
182 "name": "myapp",
183 "dependencies": {
184 "foo": {
185 "path": "../foo"
186 }
187 },
188 "transformers": ["myapp"]
189 }),
190 d.dir(
191 'lib',
192 [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).c reate();
193
194 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: {
195 "bar": {
196 "path": "../bar"
197 }
198 }),
199 d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])]) .create();
200
201 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: {
202 "myapp": {
203 "path": "../myapp"
204 }
205 }),
206 d.dir(
207 'lib',
208 [d.file("bar.dart", "import 'package:myapp/myapp.dart';")])]).crea te();
209
210 expectCycleException(
211 [
212 "myapp is transformed by myapp",
213 "myapp depends on foo",
214 "foo depends on bar",
215 "bar depends on myapp"]);
216 });
217
218 integration(
219 "allows a single-package import cycle that's unrelated to " "transformers" ,
220 () {
221 d.dir(appPath, [d.pubspec({
222 "name": "myapp",
223 "dependencies": {
224 "foo": {
225 "path": "../foo"
226 }
227 },
228 "transformers": ["myapp"]
229 }),
230 d.dir(
231 'lib',
232 [
233 d.file("myapp.dart", transformer(['foo.dart'])),
234 d.file("foo.dart", "import 'bar.dart';"),
235 d.file("bar.dart", "import 'baz.dart';"),
236 d.file("baz.dart", "import 'foo.dart';")])]).create();
237
238 expectDependencies({
239 'myapp': []
240 });
241 });
242
243 integration(
244 "allows a single-package import cycle that's related to " "transformers",
245 () {
246 d.dir(appPath, [d.pubspec({
247 "name": "myapp",
248 "dependencies": {
249 "foo": {
250 "path": "../foo"
251 }
252 },
253 "transformers": ["myapp"]
254 }),
255 d.dir(
256 'lib',
257 [
258 d.file("myapp.dart", transformer(['foo.dart'])),
259 d.file("foo.dart", "import 'bar.dart';"),
260 d.file("bar.dart", "import 'myapp.dart';"),])]).create();
261
262 expectDependencies({
263 'myapp': []
264 });
265 });
266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698