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

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

Issue 234673003: Reduce test.dart memory usage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove test output deletion. Created 6 years, 8 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
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; 5 library http_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'test_suite.dart'; // For TestUtils. 9 import 'test_suite.dart'; // For TestUtils.
10 // TODO(efortuna): Rewrite to not use the args library and simply take an 10 // TODO(efortuna): Rewrite to not use the args library and simply take an
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 List _serverList = []; 109 List _serverList = [];
110 Path _buildDirectory = null; 110 Path _buildDirectory = null;
111 Path _dartDirectory = null; 111 Path _dartDirectory = null;
112 final bool useContentSecurityPolicy; 112 final bool useContentSecurityPolicy;
113 final String runtime; 113 final String runtime;
114 114
115 TestingServers(Path buildDirectory, 115 TestingServers(Path buildDirectory,
116 this.useContentSecurityPolicy, 116 this.useContentSecurityPolicy,
117 [String this.runtime = 'none', String dartDirectory]) { 117 [String this.runtime = 'none', String dartDirectory]) {
118 _buildDirectory = TestUtils.absolutePath(buildDirectory); 118 _buildDirectory = TestUtils.absolutePath(buildDirectory);
119 _dartDirectory = dartDirectory == null ? TestUtils.dartDir() 119 _dartDirectory = dartDirectory == null ? TestUtils.dartDir
120 : new Path(dartDirectory); 120 : new Path(dartDirectory);
121 } 121 }
122 122
123 int get port => _serverList[0].port; 123 int get port => _serverList[0].port;
124 int get crossOriginPort => _serverList[1].port; 124 int get crossOriginPort => _serverList[1].port;
125 125
126 /** 126 /**
127 * [startServers] will start two Http servers. 127 * [startServers] will start two Http servers.
128 * The first server listens on [port] and sets 128 * The first server listens on [port] and sets
129 * "Access-Control-Allow-Origin: *" 129 * "Access-Control-Allow-Origin: *"
130 * The second server listens on [crossOriginPort] and sets 130 * The second server listens on [crossOriginPort] and sets
131 * "Access-Control-Allow-Origin: client:port1 131 * "Access-Control-Allow-Origin: client:port1
132 * "Access-Control-Allow-Credentials: true" 132 * "Access-Control-Allow-Credentials: true"
133 */ 133 */
134 Future startServers(String host, {int port: 0, int crossOriginPort: 0}) { 134 Future startServers(String host, {int port: 0, int crossOriginPort: 0}) {
135 return _startHttpServer(host, port: port).then((server) { 135 return _startHttpServer(host, port: port).then((server) {
136 return _startHttpServer(host, 136 return _startHttpServer(host,
137 port: crossOriginPort, 137 port: crossOriginPort,
138 allowedPort:_serverList[0].port); 138 allowedPort:_serverList[0].port);
139 }); 139 });
140 } 140 }
141 141
142 String httpServerCommandline() { 142 String httpServerCommandline() {
143 var dart = TestUtils.dartTestExecutable.toNativePath(); 143 var dart = TestUtils.dartTestExecutable.toNativePath();
144 var dartDir = TestUtils.dartDir(); 144 var dartDir = TestUtils.dartDir;
145 var script = dartDir.join(new Path("tools/testing/dart/http_server.dart")); 145 var script = dartDir.join(new Path("tools/testing/dart/http_server.dart"));
146 var buildDirectory = _buildDirectory.toNativePath(); 146 var buildDirectory = _buildDirectory.toNativePath();
147 var csp = useContentSecurityPolicy ? '--csp ' : ''; 147 var csp = useContentSecurityPolicy ? '--csp ' : '';
148 return '$dart $script -p $port -c $crossOriginPort $csp' 148 return '$dart $script -p $port -c $crossOriginPort $csp'
149 '--build-directory=$buildDirectory --runtime=$runtime'; 149 '--build-directory=$buildDirectory --runtime=$runtime';
150 } 150 }
151 151
152 void stopServers() { 152 void stopServers() {
153 for (var server in _serverList) { 153 for (var server in _serverList) {
154 server.close(); 154 server.close();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 class _Entry implements Comparable { 397 class _Entry implements Comparable {
398 final String name; 398 final String name;
399 final String displayName; 399 final String displayName;
400 400
401 _Entry(this.name, this.displayName); 401 _Entry(this.name, this.displayName);
402 402
403 int compareTo(_Entry other) { 403 int compareTo(_Entry other) {
404 return name.compareTo(other.name); 404 return name.compareTo(other.name);
405 } 405 }
406 } 406 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698