| OLD | NEW |
| (Empty) |
| 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 | |
| 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 '../serve/utils.dart'; | |
| 10 | |
| 11 main() { | |
| 12 initConfig(); | |
| 13 withBarbackVersions("any", () { | |
| 14 integration("loads different configurations from the same isolate", () { | |
| 15 // If different configurations are loaded from different isolates, a | |
| 16 // transformer can end up being loaded twice. It's even possible for the | |
| 17 // second load to use code that's transformed by the first, which is | |
| 18 // really bad. This tests sets up such a scenario. | |
| 19 // | |
| 20 // The foo package has two self-transformers: foo/first and foo/second, | |
| 21 // loaded in that order. This means that *no instances of foo/first* | |
| 22 // should ever have their code transformed by foo/second. | |
| 23 // | |
| 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 | |
| 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 | |
| 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 | |
| 30 // happen. | |
| 31 | |
| 32 d.dir("foo", [d.pubspec({ | |
| 33 "name": "foo", | |
| 34 "version": "1.0.0", | |
| 35 "transformers": [{ | |
| 36 "foo/first": { | |
| 37 "addition": " in foo" | |
| 38 } | |
| 39 }, "foo/second"] | |
| 40 }), | |
| 41 d.dir( | |
| 42 "lib", | |
| 43 [ | |
| 44 d.file("first.dart", dartTransformer('foo/first')), | |
| 45 d.file("second.dart", dartTransformer('foo/second'))])]).cre
ate(); | |
| 46 | |
| 47 d.dir(appPath, [d.pubspec({ | |
| 48 "name": "myapp", | |
| 49 "transformers": [{ | |
| 50 "foo/first": { | |
| 51 "addition": " in myapp", | |
| 52 "\$include": "web/first.dart" | |
| 53 } | |
| 54 }, { | |
| 55 "foo/second": { | |
| 56 "\$include": "web/second.dart" | |
| 57 } | |
| 58 }], | |
| 59 "dependencies": { | |
| 60 'foo': { | |
| 61 'path': '../foo' | |
| 62 } | |
| 63 } | |
| 64 }), | |
| 65 d.dir("web", [// This is transformed by foo/first. It's used to see
which | |
| 66 // transformers ran on foo/first. | |
| 67 d.file("first.dart", 'const TOKEN = "myapp/first";'), | |
| 68 // This is transformed by foo/second. It's used to see which | |
| 69 // transformers ran on foo/second. | |
| 70 d.file("second.dart", 'const TOKEN = "myapp/second";')])]).create(); | |
| 71 | |
| 72 createLockFile('myapp', sandbox: ['foo'], pkg: ['barback']); | |
| 73 | |
| 74 pubServe(); | |
| 75 | |
| 76 // The version of foo/first used on myapp should have myapp's | |
| 77 // configuration and shouldn't be transformed by foo/second. | |
| 78 requestShouldSucceed( | |
| 79 "first.dart", | |
| 80 'const TOKEN = "(myapp/first, foo/first in myapp)";'); | |
| 81 | |
| 82 // foo/second should be transformed by only foo/first. | |
| 83 requestShouldSucceed( | |
| 84 "second.dart", | |
| 85 'const TOKEN = "(myapp/second, (foo/second, foo/first in foo))";'); | |
| 86 | |
| 87 endPubServe(); | |
| 88 }); | |
| 89 }); | |
| 90 } | |
| OLD | NEW |