OLD | NEW |
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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:isolate"; | 7 import "dart:isolate"; |
8 import "process_test_util.dart"; | 8 import "process_test_util.dart"; |
9 | 9 |
10 runEnvironmentProcess(Map environment, name, callback) { | 10 runEnvironmentProcess(Map environment, name, callback) { |
11 var dartExecutable = new Options().executable; | 11 var dartExecutable = new Options().executable; |
12 var options = new ProcessOptions(); | |
13 options.environment = environment; | |
14 var printEnv = 'tests/standalone/io/print_env.dart'; | 12 var printEnv = 'tests/standalone/io/print_env.dart'; |
15 if (!new File(printEnv).existsSync()) { | 13 if (!new File(printEnv).existsSync()) { |
16 printEnv = '../$printEnv'; | 14 printEnv = '../$printEnv'; |
17 } | 15 } |
18 Process.run(dartExecutable, [printEnv, name], options).then((result) { | 16 Process.run(dartExecutable, |
19 Expect.equals(0, result.exitCode); | 17 [printEnv, name], |
20 callback(result.stdout); | 18 environment: environment) |
21 }); | 19 .then((result) { |
| 20 Expect.equals(0, result.exitCode); |
| 21 callback(result.stdout); |
| 22 }); |
22 } | 23 } |
23 | 24 |
24 testEnvironment() { | 25 testEnvironment() { |
25 var donePort = new ReceivePort(); | 26 var donePort = new ReceivePort(); |
26 Map env = Platform.environment; | 27 Map env = Platform.environment; |
27 Expect.isFalse(env.isEmpty); | 28 Expect.isFalse(env.isEmpty); |
28 // Check that some value in the environment stays the same when passed | 29 // Check that some value in the environment stays the same when passed |
29 // to another process. | 30 // to another process. |
30 for (var k in env.keys) { | 31 for (var k in env.keys) { |
31 runEnvironmentProcess(env, k, (output) { | 32 runEnvironmentProcess(env, k, (output) { |
(...skipping 13 matching lines...) Expand all Loading... |
45 }); | 46 }); |
46 // Only check one value to not spin up too many processes testing the | 47 // Only check one value to not spin up too many processes testing the |
47 // same things. | 48 // same things. |
48 break; | 49 break; |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
52 main() { | 53 main() { |
53 testEnvironment(); | 54 testEnvironment(); |
54 } | 55 } |
OLD | NEW |