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

Side by Side Diff: sdk/lib/_internal/pub/test/test_pub.dart

Issue 19494012: Report correct socket error and use HttpServer:close future in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/utils.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub
6 /// tests are integration tests that stage some stuff on the file system, run 6 /// tests are integration tests that stage some stuff on the file system, run
7 /// pub, and then validate the results. This library provides an API to build 7 /// pub, and then validate the results. This library provides an API to build
8 /// tests like that. 8 /// tests like that.
9 library test_pub; 9 library test_pub;
10 10
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:collection' show Queue; 12 import 'dart:collection' show Queue;
13 import 'dart:io' hide sleep; 13 import 'dart:io';
14 import 'dart:json' as json; 14 import 'dart:json' as json;
15 import 'dart:math'; 15 import 'dart:math';
16 import 'dart:utf'; 16 import 'dart:utf';
17 17
18 import 'package:http/testing.dart'; 18 import 'package:http/testing.dart';
19 import 'package:oauth2/oauth2.dart' as oauth2; 19 import 'package:oauth2/oauth2.dart' as oauth2;
20 import 'package:path/path.dart' as path; 20 import 'package:path/path.dart' as path;
21 import 'package:scheduled_test/scheduled_process.dart'; 21 import 'package:scheduled_test/scheduled_process.dart';
22 import 'package:scheduled_test/scheduled_server.dart'; 22 import 'package:scheduled_test/scheduled_server.dart';
23 import 'package:scheduled_test/scheduled_test.dart'; 23 import 'package:scheduled_test/scheduled_test.dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return null; 130 return null;
131 }); 131 });
132 }); 132 });
133 }, 'starting a server serving:\n${baseDir.describe()}'); 133 }, 'starting a server serving:\n${baseDir.describe()}');
134 } 134 }
135 135
136 /// Closes [_server]. Returns a [Future] that will complete after the [_server] 136 /// Closes [_server]. Returns a [Future] that will complete after the [_server]
137 /// is closed. 137 /// is closed.
138 Future _closeServer() { 138 Future _closeServer() {
139 if (_server == null) return new Future.value(); 139 if (_server == null) return new Future.value();
140 _server.close(); 140 var future = _server.close();
141 _server = null; 141 _server = null;
142 _portCompleterCache = null; 142 _portCompleterCache = null;
143 // TODO(nweiz): Remove this once issue 4155 is fixed. Pumping the event loop 143 return future;
144 // *seems* to be enough to ensure that the server is actually closed, but I'm
145 // putting this at 10ms to be safe.
146 return sleep(10);
147 } 144 }
148 145
149 /// `true` if the current test spins up an HTTP server. 146 /// `true` if the current test spins up an HTTP server.
150 bool _hasServer = false; 147 bool _hasServer = false;
151 148
152 /// The [d.DirectoryDescriptor] describing the server layout of `/api/packages` 149 /// The [d.DirectoryDescriptor] describing the server layout of `/api/packages`
153 /// on the test server. 150 /// on the test server.
154 /// 151 ///
155 /// This contains metadata for packages that are being served via 152 /// This contains metadata for packages that are being served via
156 /// [servePackages]. It's `null` if [servePackages] has not yet been called for 153 /// [servePackages]. It's `null` if [servePackages] has not yet been called for
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 bool matches(item, Map matchState) { 802 bool matches(item, Map matchState) {
806 if (item is! Pair) return false; 803 if (item is! Pair) return false;
807 return _firstMatcher.matches(item.first, matchState) && 804 return _firstMatcher.matches(item.first, matchState) &&
808 _lastMatcher.matches(item.last, matchState); 805 _lastMatcher.matches(item.last, matchState);
809 } 806 }
810 807
811 Description describe(Description description) { 808 Description describe(Description description) {
812 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 809 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
813 } 810 }
814 } 811 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698