| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.runner.browser.server; | 5 library test.runner.browser.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 /// Returns a handler that serves the contents of the "packages/" directory | 146 /// Returns a handler that serves the contents of the "packages/" directory |
| 147 /// for any URL that contains "packages/". | 147 /// for any URL that contains "packages/". |
| 148 /// | 148 /// |
| 149 /// This is a factory so it can wrap a static handler. | 149 /// This is a factory so it can wrap a static handler. |
| 150 shelf.Handler _createPackagesHandler() { | 150 shelf.Handler _createPackagesHandler() { |
| 151 var staticHandler = | 151 var staticHandler = |
| 152 createStaticHandler(_config.packageRoot, serveFilesOutsidePath: true); | 152 createStaticHandler(_config.packageRoot, serveFilesOutsidePath: true); |
| 153 | 153 |
| 154 return (request) { | 154 return (request) { |
| 155 var segments = p.url.split(shelfUrl(request).path); | 155 var segments = p.url.split(request.url.path); |
| 156 | 156 |
| 157 for (var i = 0; i < segments.length; i++) { | 157 for (var i = 0; i < segments.length; i++) { |
| 158 if (segments[i] != "packages") continue; | 158 if (segments[i] != "packages") continue; |
| 159 return staticHandler( | 159 return staticHandler( |
| 160 shelfChange(request, path: p.url.joinAll(segments.take(i + 1)))); | 160 request.change(path: p.url.joinAll(segments.take(i + 1)))); |
| 161 } | 161 } |
| 162 | 162 |
| 163 return new shelf.Response.notFound("Not found."); | 163 return new shelf.Response.notFound("Not found."); |
| 164 }; | 164 }; |
| 165 } | 165 } |
| 166 | 166 |
| 167 /// A handler that serves wrapper files used to bootstrap tests. | 167 /// A handler that serves wrapper files used to bootstrap tests. |
| 168 shelf.Response _wrapperHandler(shelf.Request request) { | 168 shelf.Response _wrapperHandler(shelf.Request request) { |
| 169 var path = p.fromUri(shelfUrl(request)); | 169 var path = p.fromUri(request.url); |
| 170 | 170 |
| 171 if (path.endsWith(".browser_test.dart")) { | 171 if (path.endsWith(".browser_test.dart")) { |
| 172 return new shelf.Response.ok(''' | 172 return new shelf.Response.ok(''' |
| 173 import "package:test/src/runner/browser/iframe_listener.dart"; | 173 import "package:test/src/runner/browser/iframe_listener.dart"; |
| 174 | 174 |
| 175 import "${p.basename(p.withoutExtension(p.withoutExtension(path)))}" as test; | 175 import "${p.basename(p.withoutExtension(p.withoutExtension(path)))}" as test; |
| 176 | 176 |
| 177 void main() { | 177 void main() { |
| 178 IframeListener.start(() => test.main); | 178 IframeListener.start(() => test.main); |
| 179 } | 179 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 await Future.wait(futures); | 406 await Future.wait(futures); |
| 407 | 407 |
| 408 if (_config.pubServeUrl == null) { | 408 if (_config.pubServeUrl == null) { |
| 409 new Directory(_compiledDir).deleteSync(recursive: true); | 409 new Directory(_compiledDir).deleteSync(recursive: true); |
| 410 } else { | 410 } else { |
| 411 _http.close(); | 411 _http.close(); |
| 412 } | 412 } |
| 413 }); | 413 }); |
| 414 } | 414 } |
| 415 } | 415 } |
| OLD | NEW |