| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file | 
 |   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. | 
 |   4  | 
 |   5 import "package:async_helper/async_helper.dart"; | 
 |   6 import "package:expect/expect.dart"; | 
 |   7 import "dart:convert"; | 
 |   8 import "dart:io"; | 
 |   9  | 
 |  10 void test({bool closeStdout, bool closeStderr}) { | 
 |  11   var scriptFile = "stdio_implicit_close_script.dart"; | 
 |  12   var script = Platform.script.resolve(scriptFile).toFilePath(); | 
 |  13  | 
 |  14   // Relying on these flags to print something specific on stdout and stderr | 
 |  15   // is brittle, but otherwise we would need to add our own flag. | 
 |  16   var arguments = [ | 
 |  17       "--print-metrics",  // Prints on stderr. | 
 |  18       "--timing",         // Prints on stdout. | 
 |  19       script, | 
 |  20   ]; | 
 |  21   if (closeStdout) arguments.add("stdout"); | 
 |  22   if (closeStderr) arguments.add("stderr"); | 
 |  23  | 
 |  24   asyncStart(); | 
 |  25   Process.run(Platform.executable, | 
 |  26               arguments, | 
 |  27               stdoutEncoding: ASCII, | 
 |  28               stderrEncoding: ASCII).then((result) { | 
 |  29                   print(result.stdout); | 
 |  30                   print(result.stderr); | 
 |  31     Expect.equals(0, result.exitCode); | 
 |  32  | 
 |  33     if (closeStdout) { | 
 |  34       Expect.equals("", result.stdout); | 
 |  35     } else { | 
 |  36       Expect.isTrue(result.stdout.contains("Timing for")); | 
 |  37     } | 
 |  38  | 
 |  39     if (closeStderr) { | 
 |  40       Expect.equals("", result.stderr); | 
 |  41     } else { | 
 |  42       Expect.isTrue(result.stderr.contains("Printing metrics")); | 
 |  43     } | 
 |  44  | 
 |  45     asyncEnd(); | 
 |  46   }); | 
 |  47 } | 
 |  48  | 
 |  49 void main() { | 
 |  50   asyncStart(); | 
 |  51   test(closeStdout: false, closeStderr: false); | 
 |  52   test(closeStdout: false, closeStderr: true); | 
 |  53   test(closeStdout: true, closeStderr: false); | 
 |  54   test(closeStdout: true, closeStderr: true); | 
 |  55   asyncEnd(); | 
 |  56 } | 
| OLD | NEW |