OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub | 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub |
7 * tests are integration tests that stage some stuff on the file system, run | 7 * tests are integration tests that stage some stuff on the file system, run |
8 * pub, and then validate the results. This library provides an API to build | 8 * pub, and then validate the results. This library provides an API to build |
9 * tests like that. | 9 * tests like that. |
10 */ | 10 */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 _schedule((_) { | 95 _schedule((_) { |
96 return _closeServer().transform((_) { | 96 return _closeServer().transform((_) { |
97 _server = new HttpServer(); | 97 _server = new HttpServer(); |
98 _server.defaultRequestHandler = (request, response) { | 98 _server.defaultRequestHandler = (request, response) { |
99 var path = request.uri.replaceFirst("/", "").split("/"); | 99 var path = request.uri.replaceFirst("/", "").split("/"); |
100 response.persistentConnection = false; | 100 response.persistentConnection = false; |
101 var stream; | 101 var stream; |
102 try { | 102 try { |
103 stream = baseDir.load(path); | 103 stream = baseDir.load(path); |
104 } catch (var e) { | 104 } catch (e) { |
105 response.statusCode = 404; | 105 response.statusCode = 404; |
106 response.contentLength = 0; | 106 response.contentLength = 0; |
107 response.outputStream.close(); | 107 response.outputStream.close(); |
108 return; | 108 return; |
109 } | 109 } |
110 | 110 |
111 var future = consumeInputStream(stream); | 111 var future = consumeInputStream(stream); |
112 future.then((data) { | 112 future.then((data) { |
113 response.statusCode = 200; | 113 response.statusCode = 200; |
114 response.contentLength = data.length; | 114 response.contentLength = data.length; |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 } | 1091 } |
1092 | 1092 |
1093 /** | 1093 /** |
1094 * Schedules a callback to be called after Pub is run with [runPub], even if it | 1094 * Schedules a callback to be called after Pub is run with [runPub], even if it |
1095 * fails. | 1095 * fails. |
1096 */ | 1096 */ |
1097 void _scheduleCleanup(_ScheduledEvent event) { | 1097 void _scheduleCleanup(_ScheduledEvent event) { |
1098 if (_scheduledCleanup == null) _scheduledCleanup = []; | 1098 if (_scheduledCleanup == null) _scheduledCleanup = []; |
1099 _scheduledCleanup.add(event); | 1099 _scheduledCleanup.add(event); |
1100 } | 1100 } |
OLD | NEW |