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

Side by Side Diff: tests/isolate/scenarios/package_data_uri_spec/package_resolve_test.dart

Issue 1585103006: - Add support for passing data: based URIs as packageConfig to (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS 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 import 'dart:io'; 5 import 'dart:io';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 final PACKAGE_URI = "package:foo/bar.dart"; 8 final PACKAGE_URI = "package:foo/bar.dart";
9 final PACKAGE_PATH = "file:///no/such/directory/bar.dart"; 9 final PACKAGE_PATH = "file:///no/such/directory/bar.dart";
10 10
11 final PACKAGE_SPEC = """
12 # This is the content of a .packages file.
13 foo:file:///no/such/directory/
14 """;
15
16
11 main([args, port]) async { 17 main([args, port]) async {
12 if (port != null) { 18 if (port != null) {
13 testPackageResolution(port); 19 testPackageResolution(port);
14 return; 20 return;
15 } 21 }
22 var data = new Uri.dataFromString(PACKAGE_SPEC);
16 var p = new RawReceivePort(); 23 var p = new RawReceivePort();
17 Isolate.spawnUri(Platform.script, 24 Isolate.spawnUri(Platform.script,
18 [], 25 [],
19 p.sendPort, 26 p.sendPort,
20 automaticPackageResolution: true); 27 packageConfig: data);
21 p.handler = (msg) { 28 p.handler = (msg) {
22 p.close(); 29 p.close();
23 if (msg is! List) { 30 if (msg is! List) {
24 print(msg.runtimeType); 31 print(msg.runtimeType);
25 throw "Failure return from spawned isolate:\n\n$msg"; 32 throw "Failure return from spawned isolate:\n\n$msg";
26 } 33 }
27 var child_pkg_config = Platform.script.resolve(".packages"); 34 if (msg[0] != data.toString()) {
28 if (msg[0] != child_pkg_config.toString()) {
29 throw "Bad package config in child isolate: ${msg[0]}\n" 35 throw "Bad package config in child isolate: ${msg[0]}\n"
30 "Expected: $child_pkg_config"; 36 "Expected: $data";
31 } 37 }
32 if (msg[1] != PACKAGE_PATH) { 38 if (msg[1] != PACKAGE_PATH) {
33 throw "Package path not matching: ${msg[1]}"; 39 throw "Package path not matching: ${msg[1]}";
34 } 40 }
35 print("SUCCESS"); 41 print("SUCCESS");
36 }; 42 };
37 print("Spawning isolate's package root: ${await Isolate.packageRoot}"); 43 print("Spawning isolate's package root: ${await Isolate.packageRoot}");
38 } 44 }
39 45
40 testPackageResolution(port) async { 46 testPackageResolution(port) async {
41 try { 47 try {
42 var packageRootStr = Platform.packageRoot; 48 var packageRootStr = Platform.packageRoot;
43 var packageConfigStr = Platform.packageConfig; 49 var packageConfigStr = Platform.packageConfig;
44 var packageConfig = await Isolate.packageConfig; 50 var packageConfig = await Isolate.packageConfig;
45 var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI)); 51 var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI));
46 print("Spawned isolate's package root flag: $packageRootStr"); 52 print("Spawned isolate's package root flag: $packageRootStr");
47 print("Spawned isolate's package config flag: $packageConfigStr"); 53 print("Spawned isolate's package config flag: $packageConfigStr");
48 print("Spawned isolate's loaded package config: $packageConfig"); 54 print("Spawned isolate's loaded package config: $packageConfig");
49 print("Spawned isolate's resolved package path: $resolvedPkg"); 55 print("Spawned isolate's resolved package path: $resolvedPkg");
50 port.send([packageConfig?.toString(), resolvedPkg?.toString()]); 56 port.send([packageConfig?.toString(), resolvedPkg?.toString()]);
51 } catch (e, s) { 57 } catch (e, s) {
52 port.send("$e\n$s\n"); 58 port.send("$e\n$s\n");
53 } 59 }
54 } 60 }
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698