| 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. | 5 /// Test infrastructure for testing pub. |
| 6 /// | 6 /// |
| 7 /// Unlike typical unit tests, most pub tests are integration tests that stage | 7 /// Unlike typical unit tests, most pub tests are integration tests that stage |
| 8 /// some stuff on the file system, run pub, and then validate the results. This | 8 /// some stuff on the file system, run pub, and then validate the results. This |
| 9 /// library provides an API to build tests like that. | 9 /// library provides an API to build tests like that. |
| 10 library test_pub; | 10 library test_pub; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 /// This server will exist only for the duration of the pub run. Subsequent | 194 /// This server will exist only for the duration of the pub run. Subsequent |
| 195 /// calls to [serve] replace the previous server. | 195 /// calls to [serve] replace the previous server. |
| 196 void serve([List<d.Descriptor> contents]) { | 196 void serve([List<d.Descriptor> contents]) { |
| 197 var baseDir = d.dir("serve-dir", contents); | 197 var baseDir = d.dir("serve-dir", contents); |
| 198 | 198 |
| 199 _hasServer = true; | 199 _hasServer = true; |
| 200 | 200 |
| 201 schedule(() { | 201 schedule(() { |
| 202 return _closeServer().then((_) { | 202 return _closeServer().then((_) { |
| 203 return shelf_io.serve((request) { | 203 return shelf_io.serve((request) { |
| 204 var path = p.posix.fromUri(request.url.path.replaceFirst("/", "")); | 204 var path = p.posix.fromUri(request.url.path); |
| 205 _requestedPaths.add(path); | 205 _requestedPaths.add(path); |
| 206 | 206 |
| 207 return validateStream(baseDir.load(path)) | 207 return validateStream(baseDir.load(path)) |
| 208 .then((stream) => new shelf.Response.ok(stream)) | 208 .then((stream) => new shelf.Response.ok(stream)) |
| 209 .catchError((error) { | 209 .catchError((error) { |
| 210 return new shelf.Response.notFound('File "$path" not found.'); | 210 return new shelf.Response.notFound('File "$path" not found.'); |
| 211 }); | 211 }); |
| 212 }, 'localhost', 0).then((server) { | 212 }, 'localhost', 0).then((server) { |
| 213 _server = server; | 213 _server = server; |
| 214 _portCompleter.complete(_server.port); | 214 _portCompleter.complete(_server.port); |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 _lastMatcher.matches(item.last, matchState); | 1001 _lastMatcher.matches(item.last, matchState); |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 Description describe(Description description) { | 1004 Description describe(Description description) { |
| 1005 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 1005 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 1006 } | 1006 } |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 /// A [StreamMatcher] that matches multiple lines of output. | 1009 /// A [StreamMatcher] that matches multiple lines of output. |
| 1010 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 1010 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
| OLD | NEW |