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

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

Powered by Google App Engine
This is Rietveld 408576698