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 /// 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 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(); |
Bob Nystrom
2013/07/22 21:02:51
How about just moving this to the end of the fn an
nweiz
2013/07/22 21:03:49
We'd still need a local variable for "server", sin
| |
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 Loading... | |
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 } |
OLD | NEW |