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

Side by Side Diff: test/global/run/resource_test.dart

Issue 1277773002: Support resources in "pub run" and "pub global run". (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « lib/src/package_locations.dart ('k') | test/run/resource_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS 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 import '../../descriptor.dart' as d;
6 import '../../test_pub.dart';
7
8 main() {
9 integration('the spawned application can load its own resource', () {
10 servePackages((builder) {
11 builder.serve("foo", "1.0.0", contents: [
12 d.dir("lib", [
13 d.file("resource.txt", "hello!")
14 ]),
15 d.dir("bin", [
16 d.file("script.dart", """
17 main() async {
18 var resource = new Resource("package:foo/resource.txt");
19
20 // TODO(nweiz): Enable this when sdk#23990 is fixed.
21 // print(resource.uri);
22
23 print(await resource.readAsString());
24 }
25 """)
26 ])
27 ]);
28 });
29
30 schedulePub(args: ["global", "activate", "foo"]);
31
32 var pub = pubRun(global: true, args: ["foo:script"]);
33
34 // TODO(nweiz): Enable this when sdk#23990 is fixed.
35 // pub.stdout.expect(p.toUri(p.join(sandboxDir, "myapp/lib/resource.txt")));
36
37 pub.stdout.expect("hello!");
38 pub.shouldExit(0);
39 });
40
41 integration("the spawned application can load a dependency's resource", () {
42 servePackages((builder) {
43 builder.serve("bar", "1.0.0", contents: [
44 d.dir("lib", [
45 d.file("resource.txt", "hello!")
46 ])
47 ]);
48
49 builder.serve("foo", "1.0.0", deps: {
50 "bar": "any"
51 }, contents: [
52 d.dir("bin", [
53 d.file("script.dart", """
54 main() async {
55 var resource = new Resource("package:bar/resource.txt");
56
57 // TODO(nweiz): Enable this when sdk#23990 is fixed.
58 // print(resource.uri);
59
60 print(await resource.readAsString());
61 }
62 """)
63 ])
64 ]);
65 });
66
67 schedulePub(args: ["global", "activate", "foo"]);
68
69 var pub = pubRun(global: true, args: ["foo:script"]);
70
71 // TODO(nweiz): Enable this when sdk#23990 is fixed.
72 // pub.stdout.expect(p.toUri(p.join(sandboxDir, "myapp/lib/resource.txt")));
73
74 pub.stdout.expect("hello!");
75 pub.shouldExit(0);
76 });
77
78 integration('a mutable application can load its own resource', () {
79 d.dir("foo", [
80 d.libPubspec("foo", "1.0.0"),
81 d.dir("lib", [
82 d.file("resource.txt", "hello!")
83 ]),
84 d.dir("bin", [
85 d.file("script.dart", """
86 main() async {
87 var resource = new Resource("package:foo/resource.txt");
88
89 // TODO(nweiz): Enable this when sdk#23990 is fixed.
90 // print(resource.uri);
91
92 print(await resource.readAsString());
93 }
94 """)
95 ])
96 ]).create();
97
98 schedulePub(args: ["global", "activate", "--source", "path", "../foo"]);
99
100 var pub = pubRun(global: true, args: ["foo:script"]);
101
102 // TODO(nweiz): Enable this when sdk#23990 is fixed.
103 // pub.stdout.expect(p.toUri(p.join(sandboxDir, "myapp/lib/resource.txt")));
104
105 pub.stdout.expect("hello!");
106 pub.shouldExit(0);
107 });
108 }
OLDNEW
« no previous file with comments | « lib/src/package_locations.dart ('k') | test/run/resource_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698