| 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 "dart:io"; | 5 import "dart:io"; |
| 6 | 6 |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 import "process_test_util.dart"; | 10 import "process_test_util.dart"; |
| 11 | 11 |
| 12 runEnvironmentProcess(Map environment, name, includeParent, callback) { | 12 runEnvironmentProcess(Map environment, name, includeParent, callback) { |
| 13 var dartExecutable = Platform.executable; | 13 var dartExecutable = Platform.executable; |
| 14 var printEnv = 'tests/standalone/io/print_env.dart'; | 14 var printEnv = 'tests/standalone/io/print_env.dart'; |
| 15 if (!new File(printEnv).existsSync()) { | 15 if (!new File(printEnv).existsSync()) { |
| 16 printEnv = '../$printEnv'; | 16 printEnv = '../$printEnv'; |
| 17 } | 17 } |
| 18 Process.run(dartExecutable, | 18 Process.run(dartExecutable, |
| 19 [printEnv, name], | 19 [printEnv, name], |
| 20 environment: environment, | 20 environment: environment, |
| 21 includeParentEnvironment: includeParent) | 21 includeParentEnvironment: includeParent) |
| 22 .then((result) { | 22 .then((result) { |
| 23 if (result.exitCode != 0) { |
| 24 print('print_env.dart subprocess failed ' |
| 25 'with exit code ${result.exitCode}'); |
| 26 print('stdout:'); |
| 27 print(result.stdout); |
| 28 print('stderr:'); |
| 29 print(result.stderr); |
| 30 } |
| 23 Expect.equals(0, result.exitCode); | 31 Expect.equals(0, result.exitCode); |
| 24 callback(result.stdout); | 32 callback(result.stdout); |
| 25 }); | 33 }); |
| 26 } | 34 } |
| 27 | 35 |
| 28 testEnvironment() { | 36 testEnvironment() { |
| 29 asyncStart(); | 37 asyncStart(); |
| 30 Map env = Platform.environment; | 38 Map env = Platform.environment; |
| 31 Expect.isFalse(env.isEmpty); | 39 Expect.isFalse(env.isEmpty); |
| 32 // Check that some value in the environment stays the same when passed | 40 // Check that some value in the environment stays the same when passed |
| (...skipping 28 matching lines...) Expand all Loading... |
| 61 runEnvironmentProcess(env, "PATH", false, (output) { | 69 runEnvironmentProcess(env, "PATH", false, (output) { |
| 62 Expect.isTrue(output.startsWith("null")); | 70 Expect.isTrue(output.startsWith("null")); |
| 63 asyncEnd(); | 71 asyncEnd(); |
| 64 }); | 72 }); |
| 65 } | 73 } |
| 66 | 74 |
| 67 main() { | 75 main() { |
| 68 testEnvironment(); | 76 testEnvironment(); |
| 69 testNoIncludeEnvironment(); | 77 testNoIncludeEnvironment(); |
| 70 } | 78 } |
| OLD | NEW |