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

Side by Side Diff: tests/standalone/io/process_environment_test.dart

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/ordered_maps_test.dart ('k') | tests/standalone/io/url_encoding_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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #source('process_test_util.dart'); 7 #source('process_test_util.dart');
8 8
9 runEnvironmentProcess(Map environment, name, callback) { 9 runEnvironmentProcess(Map environment, name, callback) {
10 var dartExecutable = new Options().executable; 10 var dartExecutable = new Options().executable;
11 var options = new ProcessOptions(); 11 var options = new ProcessOptions();
12 options.environment = environment; 12 options.environment = environment;
13 var printEnv = 'tests/standalone/io/print_env.dart'; 13 var printEnv = 'tests/standalone/io/print_env.dart';
14 if (!new File(printEnv).existsSync()) { 14 if (!new File(printEnv).existsSync()) {
15 printEnv = '../$printEnv'; 15 printEnv = '../$printEnv';
16 } 16 }
17 Process.run(dartExecutable, [printEnv, name], options).then((result) { 17 Process.run(dartExecutable, [printEnv, name], options).then((result) {
18 Expect.equals(0, result.exitCode); 18 Expect.equals(0, result.exitCode);
19 callback(result.stdout); 19 callback(result.stdout);
20 }); 20 });
21 } 21 }
22 22
23 testEnvironment() { 23 testEnvironment() {
24 var donePort = new ReceivePort(); 24 var donePort = new ReceivePort();
25 Map env = Platform.environment; 25 Map env = Platform.environment;
26 Expect.isFalse(env.isEmpty); 26 Expect.isFalse(env.isEmpty);
27 // Check that some value in the environment stays the same when passed 27 // Check that some value in the environment stays the same when passed
28 // to another process. 28 // to another process.
29 for (var k in env.getKeys()) { 29 for (var k in env.keys) {
30 runEnvironmentProcess(env, k, (output) { 30 runEnvironmentProcess(env, k, (output) {
31 // Only check startsWith. The print statements will add 31 // Only check startsWith. The print statements will add
32 // newlines at the end. 32 // newlines at the end.
33 Expect.isTrue(output.startsWith(env[k])); 33 Expect.isTrue(output.startsWith(env[k]));
34 // Add a new variable and check that it becomes an environment 34 // Add a new variable and check that it becomes an environment
35 // variable in the child process. 35 // variable in the child process.
36 var copy = new Map.from(env); 36 var copy = new Map.from(env);
37 var name = 'MYENVVAR'; 37 var name = 'MYENVVAR';
38 while (env.containsKey(name)) name = '${name}_'; 38 while (env.containsKey(name)) name = '${name}_';
39 copy[name] = 'value'; 39 copy[name] = 'value';
40 runEnvironmentProcess(copy, name, (output) { 40 runEnvironmentProcess(copy, name, (output) {
41 Expect.isTrue(output.startsWith('value')); 41 Expect.isTrue(output.startsWith('value'));
42 donePort.close(); 42 donePort.close();
43 }); 43 });
44 }); 44 });
45 // Only check one value to not spin up too many processes testing the 45 // Only check one value to not spin up too many processes testing the
46 // same things. 46 // same things.
47 break; 47 break;
48 } 48 }
49 } 49 }
50 50
51 main() { 51 main() {
52 testEnvironment(); 52 testEnvironment();
53 } 53 }
OLDNEW
« no previous file with comments | « tests/language/ordered_maps_test.dart ('k') | tests/standalone/io/url_encoding_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698