OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 // OtherResources=http_client_stays_alive_test.dart | 5 // OtherResources=http_client_stays_alive_test.dart |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 Process.run(Platform.executable, arguments).then((res) { | 47 Process.run(Platform.executable, arguments).then((res) { |
48 subscription.cancel(); | 48 subscription.cancel(); |
49 if (res.exitCode != 0) { | 49 if (res.exitCode != 0) { |
50 throw "Child exited with ${res.exitCode} instead of 0. " | 50 throw "Child exited with ${res.exitCode} instead of 0. " |
51 "(stdout: ${res.stdout}, stderr: ${res.stderr})"; | 51 "(stdout: ${res.stdout}, stderr: ${res.stderr})"; |
52 } | 52 } |
53 var seconds = sw.elapsed.inSeconds; | 53 var seconds = sw.elapsed.inSeconds; |
54 // NOTE: There is a slight chance this will cause flakiness, but there is | 54 // NOTE: There is a slight chance this will cause flakiness, but there is |
55 // no other good way of testing correctness of timing-dependent code | 55 // no other good way of testing correctness of timing-dependent code |
56 // form the outside. | 56 // form the outside. |
57 if (seconds < SECONDS || (SECONDS + 10) < seconds) { | 57 if (seconds < SECONDS || (SECONDS + 30) < seconds) { |
58 throw "Child did exit within $seconds seconds, but expected it to take " | 58 throw "Child did exit within $seconds seconds, but expected it to take " |
59 "roughly $SECONDS seconds."; | 59 "roughly $SECONDS seconds."; |
60 } | 60 } |
61 | 61 |
62 asyncEnd(); | 62 asyncEnd(); |
63 }); | 63 }); |
64 }); | 64 }); |
65 } | 65 } |
66 | 66 |
67 void runClientProcess(String url) { | 67 void runClientProcess(String url) { |
(...skipping 10 matching lines...) Expand all Loading... |
78 .then((_) => print('drained client request')); | 78 .then((_) => print('drained client request')); |
79 } | 79 } |
80 | 80 |
81 void main(List<String> args) { | 81 void main(List<String> args) { |
82 if (args.length == 1) { | 82 if (args.length == 1) { |
83 runClientProcess(args.first); | 83 runClientProcess(args.first); |
84 } else { | 84 } else { |
85 runServerProcess(); | 85 runServerProcess(); |
86 } | 86 } |
87 } | 87 } |
OLD | NEW |