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

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

Issue 2919573003: Revert "Revert "Replace the configuration map with a typed object."" (Closed)
Patch Set: Another test fix. Created 3 years, 6 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
« no previous file with comments | « tools/testing/dart/expectation_set.dart ('k') | tools/testing/dart/launch_browser.dart » ('j') | 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) 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 library http_server;
6
7 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert' show HtmlEscape;
8 import 'dart:io'; 7 import 'dart:io';
9 8
10 import 'dart:convert' show HtmlEscape; 9 import 'package:package_resolver/package_resolver.dart';
11 10
12 import 'test_suite.dart'; // For TestUtils. 11 import 'configuration.dart';
12 import 'test_suite.dart';
13 import 'vendored_pkg/args/args.dart'; 13 import 'vendored_pkg/args/args.dart';
14 import 'utils.dart'; 14 import 'utils.dart';
15 import 'package:package_resolver/package_resolver.dart';
16 15
17 class DispatchingServer { 16 class DispatchingServer {
18 HttpServer server; 17 HttpServer server;
19 Map<String, Function> _handlers = new Map<String, Function>(); 18 Map<String, Function> _handlers = new Map<String, Function>();
20 Function _notFound; 19 Function _notFound;
21 20
22 DispatchingServer( 21 DispatchingServer(
23 this.server, void onError(e), void this._notFound(HttpRequest request)) { 22 this.server, void onError(e), void this._notFound(HttpRequest request)) {
24 server.listen(_dispatchRequest, onError: onError); 23 server.listen(_dispatchRequest, onError: onError);
25 } 24 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 parser.addOption('runtime', 86 parser.addOption('runtime',
88 help: 'The runtime we are using (for csp flags).', defaultsTo: 'none'); 87 help: 'The runtime we are using (for csp flags).', defaultsTo: 'none');
89 88
90 var args = parser.parse(arguments); 89 var args = parser.parse(arguments);
91 if (args['help'] as bool) { 90 if (args['help'] as bool) {
92 print(parser.getUsage()); 91 print(parser.getUsage());
93 } else { 92 } else {
94 var servers = new TestingServers( 93 var servers = new TestingServers(
95 args['build-directory'] as String, 94 args['build-directory'] as String,
96 args['csp'] as bool, 95 args['csp'] as bool,
97 args['runtime'] as String, 96 Runtime.find(args['runtime'] as String),
98 null, 97 null,
99 args['package-root'] as String, 98 args['package-root'] as String,
100 args['packages'] as String); 99 args['packages'] as String);
101 var port = int.parse(args['port'] as String); 100 var port = int.parse(args['port'] as String);
102 var crossOriginPort = int.parse(args['crossOriginPort'] as String); 101 var crossOriginPort = int.parse(args['crossOriginPort'] as String);
103 servers 102 servers
104 .startServers(args['network'] as String, 103 .startServers(args['network'] as String,
105 port: port, crossOriginPort: crossOriginPort) 104 port: port, crossOriginPort: crossOriginPort)
106 .then((_) { 105 .then((_) {
107 DebugLogger.info('Server listening on port ${servers.port}'); 106 DebugLogger.info('Server listening on port ${servers.port}');
(...skipping 17 matching lines...) Expand all
125 "/NonExistingFile", 124 "/NonExistingFile",
126 "IntentionallyMissingFile", 125 "IntentionallyMissingFile",
127 ]; 126 ];
128 127
129 final List<HttpServer> _serverList = []; 128 final List<HttpServer> _serverList = [];
130 Uri _buildDirectory; 129 Uri _buildDirectory;
131 Uri _dartDirectory; 130 Uri _dartDirectory;
132 Uri _packageRoot; 131 Uri _packageRoot;
133 Uri _packages; 132 Uri _packages;
134 final bool useContentSecurityPolicy; 133 final bool useContentSecurityPolicy;
135 final String runtime; 134 final Runtime runtime;
136 DispatchingServer _server; 135 DispatchingServer _server;
137 SyncPackageResolver _resolver; 136 SyncPackageResolver _resolver;
138 137
139 TestingServers(String buildDirectory, this.useContentSecurityPolicy, 138 TestingServers(String buildDirectory, this.useContentSecurityPolicy,
140 [String this.runtime = 'none', 139 [this.runtime = Runtime.none,
141 String dartDirectory, 140 String dartDirectory,
142 String packageRoot, 141 String packageRoot,
143 String packages]) { 142 String packages]) {
144 _buildDirectory = Uri.base.resolveUri(new Uri.directory(buildDirectory)); 143 _buildDirectory = Uri.base.resolveUri(new Uri.directory(buildDirectory));
145 if (dartDirectory == null) { 144 if (dartDirectory == null) {
146 _dartDirectory = TestUtils.dartDirUri; 145 _dartDirectory = TestUtils.dartDirUri;
147 } else { 146 } else {
148 _dartDirectory = Uri.base.resolveUri(new Uri.directory(dartDirectory)); 147 _dartDirectory = Uri.base.resolveUri(new Uri.directory(dartDirectory));
149 } 148 }
150 if (packageRoot == null) { 149 if (packageRoot == null) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 var script = _dartDirectory.resolve('tools/testing/dart/http_server.dart'); 186 var script = _dartDirectory.resolve('tools/testing/dart/http_server.dart');
188 var buildDirectory = _buildDirectory.toFilePath(); 187 var buildDirectory = _buildDirectory.toFilePath();
189 var command = [ 188 var command = [
190 dart, 189 dart,
191 script.toFilePath(), 190 script.toFilePath(),
192 '-p', 191 '-p',
193 port, 192 port,
194 '-c', 193 '-c',
195 crossOriginPort, 194 crossOriginPort,
196 '--build-directory=$buildDirectory', 195 '--build-directory=$buildDirectory',
197 '--runtime=$runtime' 196 '--runtime=${runtime.name}'
198 ]; 197 ];
199 if (useContentSecurityPolicy) { 198 if (useContentSecurityPolicy) {
200 command.add('--csp'); 199 command.add('--csp');
201 } 200 }
202 if (_packages != null) { 201 if (_packages != null) {
203 command.add('--packages=${_packages.toFilePath()}'); 202 command.add('--packages=${_packages.toFilePath()}');
204 } else if (_packageRoot != null) { 203 } else if (_packageRoot != null) {
205 command.add('--package-root=${_packageRoot.toFilePath()}'); 204 command.add('--package-root=${_packageRoot.toFilePath()}');
206 } 205 }
207 return command.join(' '); 206 return command.join(' ');
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 class _Entry implements Comparable<_Entry> { 469 class _Entry implements Comparable<_Entry> {
471 final String name; 470 final String name;
472 final String displayName; 471 final String displayName;
473 472
474 _Entry(this.name, this.displayName); 473 _Entry(this.name, this.displayName);
475 474
476 int compareTo(_Entry other) { 475 int compareTo(_Entry other) {
477 return name.compareTo(other.name); 476 return name.compareTo(other.name);
478 } 477 }
479 } 478 }
OLDNEW
« no previous file with comments | « tools/testing/dart/expectation_set.dart ('k') | tools/testing/dart/launch_browser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698