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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 }); | 140 }); |
141 }, 'starting a server serving:\n${baseDir.describe()}'); | 141 }, 'starting a server serving:\n${baseDir.describe()}'); |
142 } | 142 } |
143 | 143 |
144 /// Closes [_server]. Returns a [Future] that will complete after the [_server] | 144 /// Closes [_server]. Returns a [Future] that will complete after the [_server] |
145 /// is closed. | 145 /// is closed. |
146 Future _closeServer() { | 146 Future _closeServer() { |
147 if (_server == null) return new Future.value(); | 147 if (_server == null) return new Future.value(); |
148 var future = _server.close(); | 148 var future = _server.close(); |
149 _server = null; | 149 _server = null; |
| 150 _hasServer = false; |
150 _portCompleterCache = null; | 151 _portCompleterCache = null; |
151 return future; | 152 return future; |
152 } | 153 } |
153 | 154 |
154 /// `true` if the current test spins up an HTTP server. | 155 /// `true` if the current test spins up an HTTP server. |
155 bool _hasServer = false; | 156 bool _hasServer = false; |
156 | 157 |
157 /// The [d.DirectoryDescriptor] describing the server layout of `/api/packages` | 158 /// The [d.DirectoryDescriptor] describing the server layout of `/api/packages` |
158 /// on the test server. | 159 /// on the test server. |
159 /// | 160 /// |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 bool matches(item, Map matchState) { | 859 bool matches(item, Map matchState) { |
859 if (item is! Pair) return false; | 860 if (item is! Pair) return false; |
860 return _firstMatcher.matches(item.first, matchState) && | 861 return _firstMatcher.matches(item.first, matchState) && |
861 _lastMatcher.matches(item.last, matchState); | 862 _lastMatcher.matches(item.last, matchState); |
862 } | 863 } |
863 | 864 |
864 Description describe(Description description) { | 865 Description describe(Description description) { |
865 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 866 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
866 } | 867 } |
867 } | 868 } |
OLD | NEW |