Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: tools/testing/dart/http_server.dart

Issue 11971012: Don't exit test script on an error in the http server. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library http_server; 5 library http_server;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'test_suite.dart'; // For TestUtils. 9 import 'test_suite.dart'; // For TestUtils.
10 import '../../../pkg/args/lib/args.dart'; 10 import '../../../pkg/args/lib/args.dart';
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 static setPackageRootDir(Map configuration) { 66 static setPackageRootDir(Map configuration) {
67 _packageRootDir = TestUtils.currentWorkingDirectory.join( 67 _packageRootDir = TestUtils.currentWorkingDirectory.join(
68 new Path(TestUtils.buildDir(configuration))); 68 new Path(TestUtils.buildDir(configuration)));
69 } 69 }
70 70
71 static startHttpServer(String host, {int allowedPort:-1, int port: 0}) { 71 static startHttpServer(String host, {int allowedPort:-1, int port: 0}) {
72 var basePath = TestUtils.dartDir(); 72 var basePath = TestUtils.dartDir();
73 var httpServer = new HttpServer(); 73 var httpServer = new HttpServer();
74 var packagesDirName = 'packages'; 74 var packagesDirName = 'packages';
75 httpServer.onError = (e) { 75 httpServer.onError = (e) {
76 // Consider errors in the builtin http server fatal. 76 // TODO(ricow): Once we have a debug log we should write this out there.
77 // Intead of just throwing the exception we print
78 // a message that makes it clearer what happened.
79 print('Test http server error: $e'); 77 print('Test http server error: $e');
80 exit(1);
81 }; 78 };
82 httpServer.defaultRequestHandler = (request, resp) { 79 httpServer.defaultRequestHandler = (request, resp) {
83 var requestPath = new Path(request.path.substring(1)).canonicalize(); 80 var requestPath = new Path(request.path.substring(1)).canonicalize();
84 var path = basePath.join(requestPath); 81 var path = basePath.join(requestPath);
85 var file = new File(path.toNativePath()); 82 var file = new File(path.toNativePath());
86 83
87 if (requestPath.segments().contains(packagesDirName)) { 84 if (requestPath.segments().contains(packagesDirName)) {
88 // Essentially implement the packages path rewriting, so we don't have 85 // Essentially implement the packages path rewriting, so we don't have
89 // to pass environment variables to the browsers. 86 // to pass environment variables to the browsers.
90 var requestPathStr = requestPath.toNativePath().substring( 87 var requestPathStr = requestPath.toNativePath().substring(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 }); 133 });
137 134
138 httpServer.listen(host, port); 135 httpServer.listen(host, port);
139 serverList.add(httpServer); 136 serverList.add(httpServer);
140 } 137 }
141 138
142 static terminateHttpServers() { 139 static terminateHttpServers() {
143 for (var server in serverList) server.close(); 140 for (var server in serverList) server.close();
144 } 141 }
145 } 142 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698