Index: sdk/lib/_internal/pub_generated/test/transformers_needed_by_transformers/cycle_test.dart |
diff --git a/sdk/lib/_internal/pub_generated/test/transformers_needed_by_transformers/cycle_test.dart b/sdk/lib/_internal/pub_generated/test/transformers_needed_by_transformers/cycle_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fefc3cf0072167c67864126cc1db0f9d042999e2 |
--- /dev/null |
+++ b/sdk/lib/_internal/pub_generated/test/transformers_needed_by_transformers/cycle_test.dart |
@@ -0,0 +1,231 @@ |
+library pub_tests; |
+import '../descriptor.dart' as d; |
+import '../test_pub.dart'; |
+import 'utils.dart'; |
+void main() { |
+ initConfig(); |
+ integration( |
+ "allows a package dependency cycle that's unrelated to " "transformers", |
+ () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["myapp/first", "myapp/second"] |
+ }), |
+ d.dir( |
+ 'lib', |
+ [ |
+ d.file("first.dart", transformer()), |
+ d.file("second.dart", transformer())])]).create(); |
+ d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
+ "bar": { |
+ "path": "../bar" |
+ } |
+ })]).create(); |
+ d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
+ "baz": { |
+ "path": "../baz" |
+ } |
+ })]).create(); |
+ d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ })]).create(); |
+ expectDependencies({ |
+ 'myapp/first': [], |
+ 'myapp/second': ['myapp/first'] |
+ }); |
+ }); |
+ integration( |
+ "disallows a package dependency cycle that may be related to " "transformers", |
+ () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["myapp/first", "myapp/second"] |
+ }), |
+ d.dir( |
+ 'lib', |
+ [ |
+ d.file("first.dart", transformer()), |
+ d.file("second.dart", transformer())])]).create(); |
+ d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
+ "bar": { |
+ "path": "../bar" |
+ } |
+ })]).create(); |
+ d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
+ "myapp": { |
+ "path": "../myapp" |
+ } |
+ })]).create(); |
+ expectCycleException( |
+ [ |
+ "myapp is transformed by myapp/second", |
+ "myapp depends on foo", |
+ "foo depends on bar", |
+ "bar depends on myapp", |
+ "myapp is transformed by myapp/first"]); |
+ }); |
+ integration("disallows a transformation dependency cycle", () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["foo"] |
+ }), d.dir('lib', [d.file("myapp.dart", transformer())])]).create(); |
+ d.dir("foo", [d.pubspec({ |
+ "name": "foo", |
+ "dependencies": { |
+ "bar": { |
+ "path": "../bar" |
+ } |
+ }, |
+ "transformers": ["bar"] |
+ }), d.dir('lib', [d.file("foo.dart", transformer())])]).create(); |
+ d.dir("bar", [d.pubspec({ |
+ "name": "bar", |
+ "dependencies": { |
+ "myapp": { |
+ "path": "../myapp" |
+ } |
+ }, |
+ "transformers": ["myapp"] |
+ }), d.dir('lib', [d.file("bar.dart", transformer())])]).create(); |
+ expectCycleException( |
+ [ |
+ "bar is transformed by myapp", |
+ "myapp is transformed by foo", |
+ "foo is transformed by bar"]); |
+ }); |
+ integration( |
+ "allows a cross-package import cycle that's unrelated to " "transformers", |
+ () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["myapp"] |
+ }), |
+ d.dir( |
+ 'lib', |
+ [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).create(); |
+ d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
+ "bar": { |
+ "path": "../bar" |
+ } |
+ }), |
+ d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])]).create(); |
+ d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
+ "baz": { |
+ "path": "../baz" |
+ } |
+ }), |
+ d.dir('lib', [d.file("bar.dart", "import 'package:baz/baz.dart';")])]).create(); |
+ d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }), |
+ d.dir('lib', [d.file("baz.dart", "import 'package:foo/foo.dart';")])]).create(); |
+ expectDependencies({ |
+ 'myapp': [] |
+ }); |
+ }); |
+ integration( |
+ "disallows a cross-package import cycle that's related to " "transformers", |
+ () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["myapp"] |
+ }), |
+ d.dir( |
+ 'lib', |
+ [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).create(); |
+ d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
+ "bar": { |
+ "path": "../bar" |
+ } |
+ }), |
+ d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])]).create(); |
+ d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
+ "myapp": { |
+ "path": "../myapp" |
+ } |
+ }), |
+ d.dir( |
+ 'lib', |
+ [d.file("bar.dart", "import 'package:myapp/myapp.dart';")])]).create(); |
+ expectCycleException( |
+ [ |
+ "myapp is transformed by myapp", |
+ "myapp depends on foo", |
+ "foo depends on bar", |
+ "bar depends on myapp"]); |
+ }); |
+ integration( |
+ "allows a single-package import cycle that's unrelated to " "transformers", |
+ () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["myapp"] |
+ }), |
+ d.dir( |
+ 'lib', |
+ [ |
+ d.file("myapp.dart", transformer(['foo.dart'])), |
+ d.file("foo.dart", "import 'bar.dart';"), |
+ d.file("bar.dart", "import 'baz.dart';"), |
+ d.file("baz.dart", "import 'foo.dart';")])]).create(); |
+ expectDependencies({ |
+ 'myapp': [] |
+ }); |
+ }); |
+ integration( |
+ "allows a single-package import cycle that's related to " "transformers", |
+ () { |
+ d.dir(appPath, [d.pubspec({ |
+ "name": "myapp", |
+ "dependencies": { |
+ "foo": { |
+ "path": "../foo" |
+ } |
+ }, |
+ "transformers": ["myapp"] |
+ }), |
+ d.dir( |
+ 'lib', |
+ [ |
+ d.file("myapp.dart", transformer(['foo.dart'])), |
+ d.file("foo.dart", "import 'bar.dart';"), |
+ d.file("bar.dart", "import 'myapp.dart';")])]).create(); |
+ expectDependencies({ |
+ 'myapp': [] |
+ }); |
+ }); |
+} |