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

Side by Side Diff: sdk/lib/_internal/pub/test/transformer/loads_different_configurations_from_the_same_isolate_test.dart

Issue 1165473002: Start pulling pub from its own repo. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review changes Created 5 years, 6 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
OLDNEW
(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", [
33 d.pubspec({
34 "name": "foo",
35 "version": "1.0.0",
36 "transformers": [
37 {"foo/first": {"addition": " in foo"}},
38 "foo/second"
39 ]
40 }),
41 d.dir("lib", [
42 d.file("first.dart", dartTransformer('foo/first')),
43 d.file("second.dart", dartTransformer('foo/second'))
44 ])
45 ]).create();
46
47 d.dir(appPath, [
48 d.pubspec({
49 "name": "myapp",
50 "transformers": [
51 {
52 "foo/first": {
53 "addition": " in myapp",
54 "\$include": "web/first.dart"
55 }
56 },
57 {"foo/second": {"\$include": "web/second.dart"}}
58 ],
59 "dependencies": {'foo': {'path': '../foo'}}
60 }),
61 d.dir("web", [
62 // This is transformed by foo/first. It's used to see which
63 // transformers ran on foo/first.
64 d.file("first.dart", 'const TOKEN = "myapp/first";'),
65
66 // This is transformed by foo/second. It's used to see which
67 // transformers ran on foo/second.
68 d.file("second.dart", 'const TOKEN = "myapp/second";')
69 ])
70 ]).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("first.dart",
79 'const TOKEN = "(myapp/first, foo/first in myapp)";');
80
81 // foo/second should be transformed by only foo/first.
82 requestShouldSucceed("second.dart",
83 'const TOKEN = "(myapp/second, (foo/second, foo/first in foo))";');
84
85 endPubServe();
86 });
87 });
88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698