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 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 | 8 |
9 import '../../../lib/src/io.dart'; | 9 import '../../../lib/src/io.dart'; |
10 import '../../descriptor.dart' as d; | 10 import '../../descriptor.dart' as d; |
11 import '../../test_pub.dart'; | 11 import '../../test_pub.dart'; |
12 import '../utils.dart'; | 12 import '../utils.dart'; |
13 | 13 |
14 main() { | 14 main() { |
15 // TODO(rnystrom): Split into independent tests. | 15 // TODO(rnystrom): Split into independent tests. |
16 initConfig(); | 16 initConfig(); |
17 integration("pathToUrls converts asset ids to matching URL paths", () { | 17 integration("pathToUrls converts asset ids to matching URL paths", () { |
18 d.dir("foo", [ | 18 d.dir( |
19 d.libPubspec("foo", "1.0.0"), | 19 "foo", |
20 d.dir("lib", [ | 20 [ |
21 d.file("foo.dart", "foo() => null;") | 21 d.libPubspec("foo", "1.0.0"), |
22 ]) | 22 d.dir("lib", [d.file("foo.dart", "foo() => null;")])]).create(); |
23 ]).create(); | |
24 | 23 |
25 d.dir(appPath, [ | 24 d.dir(appPath, [d.appPubspec({ |
26 d.appPubspec({"foo": {"path": "../foo"}}), | 25 "foo": { |
27 d.dir("test", [ | 26 "path": "../foo" |
28 d.file("index.html", "<body>"), | 27 } |
29 d.dir("sub", [ | 28 }), |
30 d.file("bar.html", "bar"), | 29 d.dir( |
31 ]) | 30 "test", |
32 ]), | 31 [d.file("index.html", "<body>"), d.dir("sub", [d.file("bar.html",
"bar"),])]), |
33 d.dir("lib", [ | 32 d.dir("lib", [d.file("app.dart", "app() => null;")]), |
34 d.file("app.dart", "app() => null;") | 33 d.dir( |
35 ]), | 34 "web", |
36 d.dir("web", [ | 35 [d.file("index.html", "<body>"), d.dir("sub", [d.file("bar.html",
"bar"),])]), |
37 d.file("index.html", "<body>"), | 36 d.dir("randomdir", [d.file("index.html", "<body>")])]).create(); |
38 d.dir("sub", [ | |
39 d.file("bar.html", "bar"), | |
40 ]) | |
41 ]), | |
42 d.dir("randomdir", [ | |
43 d.file("index.html", "<body>") | |
44 ]) | |
45 ]).create(); | |
46 | 37 |
47 pubServe(args: ["test", "web", "randomdir"], shouldGetFirst: true); | 38 pubServe(args: ["test", "web", "randomdir"], shouldGetFirst: true); |
48 | 39 |
49 // Paths in web/. | 40 // Paths in web/. |
50 expectWebSocketResult("pathToUrls", { | 41 expectWebSocketResult("pathToUrls", { |
51 "path": p.join("web", "index.html") | 42 "path": p.join("web", "index.html") |
52 }, { | 43 }, { |
53 "urls": [getServerUrl("web", "index.html")] | 44 "urls": [getServerUrl("web", "index.html")] |
54 }); | 45 }); |
55 | 46 |
(...skipping 19 matching lines...) Expand all Loading... |
75 // A non-default directory. | 66 // A non-default directory. |
76 expectWebSocketResult("pathToUrls", { | 67 expectWebSocketResult("pathToUrls", { |
77 "path": p.join("randomdir", "index.html") | 68 "path": p.join("randomdir", "index.html") |
78 }, { | 69 }, { |
79 "urls": [getServerUrl("randomdir", "index.html")] | 70 "urls": [getServerUrl("randomdir", "index.html")] |
80 }); | 71 }); |
81 | 72 |
82 // A path in lib/. | 73 // A path in lib/. |
83 expectWebSocketResult("pathToUrls", { | 74 expectWebSocketResult("pathToUrls", { |
84 "path": p.join("lib", "app.dart") | 75 "path": p.join("lib", "app.dart") |
85 }, {"urls": [ | 76 }, { |
86 getServerUrl("test", "packages/myapp/app.dart"), | 77 "urls": [ |
87 getServerUrl("web", "packages/myapp/app.dart"), | 78 getServerUrl("test", "packages/myapp/app.dart"), |
88 getServerUrl("randomdir", "packages/myapp/app.dart") | 79 getServerUrl("web", "packages/myapp/app.dart"), |
89 ]}); | 80 getServerUrl("randomdir", "packages/myapp/app.dart")] |
| 81 }); |
90 | 82 |
91 // A path to this package in packages/. | 83 // A path to this package in packages/. |
92 expectWebSocketResult("pathToUrls", { | 84 expectWebSocketResult("pathToUrls", { |
93 "path": p.join("packages", "myapp", "app.dart") | 85 "path": p.join("packages", "myapp", "app.dart") |
94 }, {"urls": [ | 86 }, { |
95 getServerUrl("test", "packages/myapp/app.dart"), | 87 "urls": [ |
96 getServerUrl("web", "packages/myapp/app.dart"), | 88 getServerUrl("test", "packages/myapp/app.dart"), |
97 getServerUrl("randomdir", "packages/myapp/app.dart") | 89 getServerUrl("web", "packages/myapp/app.dart"), |
98 ]}); | 90 getServerUrl("randomdir", "packages/myapp/app.dart")] |
| 91 }); |
99 | 92 |
100 // A path to another package in packages/. | 93 // A path to another package in packages/. |
101 expectWebSocketResult("pathToUrls", { | 94 expectWebSocketResult("pathToUrls", { |
102 "path": p.join("packages", "foo", "foo.dart") | 95 "path": p.join("packages", "foo", "foo.dart") |
103 }, {"urls": [ | 96 }, { |
104 getServerUrl("test", "packages/foo/foo.dart"), | 97 "urls": [ |
105 getServerUrl("web", "packages/foo/foo.dart"), | 98 getServerUrl("test", "packages/foo/foo.dart"), |
106 getServerUrl("randomdir", "packages/foo/foo.dart") | 99 getServerUrl("web", "packages/foo/foo.dart"), |
107 ]}); | 100 getServerUrl("randomdir", "packages/foo/foo.dart")] |
| 101 }); |
108 | 102 |
109 // A relative path to another package's lib/ directory. | 103 // A relative path to another package's lib/ directory. |
110 expectWebSocketResult("pathToUrls", { | 104 expectWebSocketResult("pathToUrls", { |
111 "path": p.join("..", "foo", "lib", "foo.dart") | 105 "path": p.join("..", "foo", "lib", "foo.dart") |
112 }, {"urls": [ | 106 }, { |
113 getServerUrl("test", "packages/foo/foo.dart"), | 107 "urls": [ |
114 getServerUrl("web", "packages/foo/foo.dart"), | 108 getServerUrl("test", "packages/foo/foo.dart"), |
115 getServerUrl("randomdir", "packages/foo/foo.dart") | 109 getServerUrl("web", "packages/foo/foo.dart"), |
116 ]}); | 110 getServerUrl("randomdir", "packages/foo/foo.dart")] |
| 111 }); |
117 | 112 |
118 // Note: Using canonicalize here because pub gets the path to the | 113 // Note: Using canonicalize here because pub gets the path to the |
119 // entrypoint package from the working directory, which has had symlinks | 114 // entrypoint package from the working directory, which has had symlinks |
120 // resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we | 115 // resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we |
121 // need to accomodate that. | 116 // need to accomodate that. |
122 | 117 |
123 // An absolute path to another package's lib/ directory. | 118 // An absolute path to another package's lib/ directory. |
124 expectWebSocketResult("pathToUrls", { | 119 expectWebSocketResult("pathToUrls", { |
125 "path": canonicalize(p.join(sandboxDir, "foo", "lib", "foo.dart")) | 120 "path": canonicalize(p.join(sandboxDir, "foo", "lib", "foo.dart")) |
126 }, {"urls": [ | 121 }, { |
127 getServerUrl("test", "packages/foo/foo.dart"), | 122 "urls": [ |
128 getServerUrl("web", "packages/foo/foo.dart"), | 123 getServerUrl("test", "packages/foo/foo.dart"), |
129 getServerUrl("randomdir", "packages/foo/foo.dart") | 124 getServerUrl("web", "packages/foo/foo.dart"), |
130 ]}); | 125 getServerUrl("randomdir", "packages/foo/foo.dart")] |
| 126 }); |
131 | 127 |
132 endPubServe(); | 128 endPubServe(); |
133 }); | 129 }); |
134 } | 130 } |
OLD | NEW |