| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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 pub_tests; | 5 library pub_tests; |
| 6 | 6 |
| 7 import '../descriptor.dart' as d; | 7 import '../descriptor.dart' as d; |
| 8 import '../test_pub.dart'; | 8 import '../test_pub.dart'; |
| 9 import '../serve/utils.dart'; | 9 import '../serve/utils.dart'; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // should ever have their code transformed by foo/second. | 22 // should ever have their code transformed by foo/second. |
| 23 // | 23 // |
| 24 // The myapp package also has a reference to foo/first. This reference has | 24 // The myapp package also has a reference to foo/first. This reference has |
| 25 // a different configuration than foo's, which means that if it's loaded | 25 // a different configuration than foo's, which means that if it's loaded |
| 26 // in a separate isolate, it will be loaded after all of foo's | 26 // in a separate isolate, it will be loaded after all of foo's |
| 27 // transformers have run. This means that foo/first.dart will have been | 27 // transformers have run. This means that foo/first.dart will have been |
| 28 // transformed by foo/first and foo/second, causing it to have different | 28 // transformed by foo/first and foo/second, causing it to have different |
| 29 // code than the previous instance. This tests asserts that that doesn't | 29 // code than the previous instance. This tests asserts that that doesn't |
| 30 // happen. | 30 // happen. |
| 31 | 31 |
| 32 d.dir("foo", [ | 32 d.dir("foo", [d.pubspec({ |
| 33 d.pubspec({ | |
| 34 "name": "foo", | 33 "name": "foo", |
| 35 "version": "1.0.0", | 34 "version": "1.0.0", |
| 36 "transformers": [ | 35 "transformers": [{ |
| 37 {"foo/first": {"addition": " in foo"}}, | 36 "foo/first": { |
| 38 "foo/second" | 37 "addition": " in foo" |
| 39 ] | 38 } |
| 39 }, "foo/second"] |
| 40 }), | 40 }), |
| 41 d.dir("lib", [ | 41 d.dir( |
| 42 d.file("first.dart", dartTransformer('foo/first')), | 42 "lib", |
| 43 d.file("second.dart", dartTransformer('foo/second')) | 43 [ |
| 44 ]) | 44 d.file("first.dart", dartTransformer('foo/first')), |
| 45 ]).create(); | 45 d.file("second.dart", dartTransformer('foo/second'))])]).cre
ate(); |
| 46 | 46 |
| 47 d.dir(appPath, [ | 47 d.dir(appPath, [d.pubspec({ |
| 48 d.pubspec({ | |
| 49 "name": "myapp", | 48 "name": "myapp", |
| 50 "transformers": [ | 49 "transformers": [{ |
| 51 { | |
| 52 "foo/first": { | 50 "foo/first": { |
| 53 "addition": " in myapp", | 51 "addition": " in myapp", |
| 54 "\$include": "web/first.dart" | 52 "\$include": "web/first.dart" |
| 55 } | 53 } |
| 56 }, | 54 }, { |
| 57 {"foo/second": {"\$include": "web/second.dart"}} | 55 "foo/second": { |
| 58 ], | 56 "\$include": "web/second.dart" |
| 59 "dependencies": {'foo': {'path': '../foo'}} | 57 } |
| 58 }], |
| 59 "dependencies": { |
| 60 'foo': { |
| 61 'path': '../foo' |
| 62 } |
| 63 } |
| 60 }), | 64 }), |
| 61 d.dir("web", [ | 65 d.dir("web", [// This is transformed by foo/first. It's used to see
which |
| 62 // This is transformed by foo/first. It's used to see which | |
| 63 // transformers ran on foo/first. | 66 // transformers ran on foo/first. |
| 64 d.file("first.dart", 'const TOKEN = "myapp/first";'), | 67 d.file("first.dart", 'const TOKEN = "myapp/first";'), |
| 65 | 68 // This is transformed by foo/second. It's used to see which |
| 66 // This is transformed by foo/second. It's used to see which | |
| 67 // transformers ran on foo/second. | 69 // transformers ran on foo/second. |
| 68 d.file("second.dart", 'const TOKEN = "myapp/second";') | 70 d.file("second.dart", 'const TOKEN = "myapp/second";')])]).create(); |
| 69 ]) | |
| 70 ]).create(); | |
| 71 | 71 |
| 72 createLockFile('myapp', sandbox: ['foo'], pkg: ['barback']); | 72 createLockFile('myapp', sandbox: ['foo'], pkg: ['barback']); |
| 73 | 73 |
| 74 pubServe(); | 74 pubServe(); |
| 75 | 75 |
| 76 // The version of foo/first used on myapp should have myapp's | 76 // The version of foo/first used on myapp should have myapp's |
| 77 // configuration and shouldn't be transformed by foo/second. | 77 // configuration and shouldn't be transformed by foo/second. |
| 78 requestShouldSucceed("first.dart", | 78 requestShouldSucceed( |
| 79 "first.dart", |
| 79 'const TOKEN = "(myapp/first, foo/first in myapp)";'); | 80 'const TOKEN = "(myapp/first, foo/first in myapp)";'); |
| 80 | 81 |
| 81 // foo/second should be transformed by only foo/first. | 82 // foo/second should be transformed by only foo/first. |
| 82 requestShouldSucceed("second.dart", | 83 requestShouldSucceed( |
| 84 "second.dart", |
| 83 'const TOKEN = "(myapp/second, (foo/second, foo/first in foo))";'); | 85 'const TOKEN = "(myapp/second, (foo/second, foo/first in foo))";'); |
| 84 | 86 |
| 85 endPubServe(); | 87 endPubServe(); |
| 86 }); | 88 }); |
| 87 }); | 89 }); |
| 88 } | 90 } |
| OLD | NEW |