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

Unified Diff: pkg/http_multi_server/test/http_multi_server_test.dart

Issue 411203002: Swallow errors in subscriptions in http_multi_server.. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http_multi_server/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http_multi_server/test/http_multi_server_test.dart
diff --git a/pkg/http_multi_server/test/http_multi_server_test.dart b/pkg/http_multi_server/test/http_multi_server_test.dart
index a3d9062067bced9da28b8452eccec18c0212a906..0140ee7c8968c37947dd33ade9dd0e8b05016b66 100644
--- a/pkg/http_multi_server/test/http_multi_server_test.dart
+++ b/pkg/http_multi_server/test/http_multi_server_test.dart
@@ -108,7 +108,7 @@ void main() {
expect(http.read("http://127.0.0.1:${server.port}/"),
completion(equals("got request")));
- return supportsIpV6.then((supportsIpV6) {
+ return _supportsIpV6.then((supportsIpV6) {
if (!supportsIpV6) return;
expect(http.read("http://[::1]:${server.port}/"),
completion(equals("got request")));
@@ -117,6 +117,26 @@ void main() {
});
}
+/// A cache for [supportsIpV6].
+bool _supportsIpV6Cache;
+
+// TODO(nweiz): This is known to be inaccurate on Windows machines with IPv6
+// disabled (issue 19815). Tests will fail on such machines.
+/// Returns whether this computer supports binding to IPv6 addresses.
+Future<bool> get _supportsIpV6 {
+ if (_supportsIpV6Cache != null) return new Future.value(_supportsIpV6Cache);
+
+ return ServerSocket.bind(InternetAddress.LOOPBACK_IP_V6, 0).then((socket) {
+ _supportsIpV6Cache = true;
+ socket.close();
+ return true;
+ }).catchError((error) {
+ if (error is! SocketException) throw error;
+ _supportsIpV6Cache = false;
+ return false;
+ });
+}
+
/// Makes a GET request to the root of [server] and returns the response.
Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server));
« no previous file with comments | « pkg/http_multi_server/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698