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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/package_locations.dart ('k') | test/run/resource_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/global/run/resource_test.dart
diff --git a/test/global/run/resource_test.dart b/test/global/run/resource_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a8c93e3a6cd8def92f0cc72cd81750a1b80705ec
--- /dev/null
+++ b/test/global/run/resource_test.dart
@@ -0,0 +1,108 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import '../../descriptor.dart' as d;
+import '../../test_pub.dart';
+
+main() {
+ integration('the spawned application can load its own resource', () {
+ servePackages((builder) {
+ builder.serve("foo", "1.0.0", contents: [
+ d.dir("lib", [
+ d.file("resource.txt", "hello!")
+ ]),
+ d.dir("bin", [
+ d.file("script.dart", """
+main() async {
+ var resource = new Resource("package:foo/resource.txt");
+
+ // TODO(nweiz): Enable this when sdk#23990 is fixed.
+ // print(resource.uri);
+
+ print(await resource.readAsString());
+}
+""")
+ ])
+ ]);
+ });
+
+ schedulePub(args: ["global", "activate", "foo"]);
+
+ var pub = pubRun(global: true, args: ["foo:script"]);
+
+ // TODO(nweiz): Enable this when sdk#23990 is fixed.
+ // pub.stdout.expect(p.toUri(p.join(sandboxDir, "myapp/lib/resource.txt")));
+
+ pub.stdout.expect("hello!");
+ pub.shouldExit(0);
+ });
+
+ integration("the spawned application can load a dependency's resource", () {
+ servePackages((builder) {
+ builder.serve("bar", "1.0.0", contents: [
+ d.dir("lib", [
+ d.file("resource.txt", "hello!")
+ ])
+ ]);
+
+ builder.serve("foo", "1.0.0", deps: {
+ "bar": "any"
+ }, contents: [
+ d.dir("bin", [
+ d.file("script.dart", """
+main() async {
+ var resource = new Resource("package:bar/resource.txt");
+
+ // TODO(nweiz): Enable this when sdk#23990 is fixed.
+ // print(resource.uri);
+
+ print(await resource.readAsString());
+}
+""")
+ ])
+ ]);
+ });
+
+ schedulePub(args: ["global", "activate", "foo"]);
+
+ var pub = pubRun(global: true, args: ["foo:script"]);
+
+ // TODO(nweiz): Enable this when sdk#23990 is fixed.
+ // pub.stdout.expect(p.toUri(p.join(sandboxDir, "myapp/lib/resource.txt")));
+
+ pub.stdout.expect("hello!");
+ pub.shouldExit(0);
+ });
+
+ integration('a mutable application can load its own resource', () {
+ d.dir("foo", [
+ d.libPubspec("foo", "1.0.0"),
+ d.dir("lib", [
+ d.file("resource.txt", "hello!")
+ ]),
+ d.dir("bin", [
+ d.file("script.dart", """
+main() async {
+ var resource = new Resource("package:foo/resource.txt");
+
+ // TODO(nweiz): Enable this when sdk#23990 is fixed.
+ // print(resource.uri);
+
+ print(await resource.readAsString());
+}
+""")
+ ])
+ ]).create();
+
+ schedulePub(args: ["global", "activate", "--source", "path", "../foo"]);
+
+ var pub = pubRun(global: true, args: ["foo:script"]);
+
+ // TODO(nweiz): Enable this when sdk#23990 is fixed.
+ // pub.stdout.expect(p.toUri(p.join(sandboxDir, "myapp/lib/resource.txt")));
+
+ pub.stdout.expect("hello!");
+ pub.shouldExit(0);
+ });
+}
« 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