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

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

Issue 11931025: Unbreak local browser testing. (Closed) Base URL: https://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 | tools/testing/dart/temp_package_root/args/args.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) 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 'temp_package_root/args/args.dart';
Jennifer Messerly 2013/01/16 20:03:44 Shouldn't be done in this change, but I wanted to
ahe 2013/01/16 20:49:54 Perhaps we could just rewrite this program to take
10 11
12 main() {
13 /** Convenience method for local testing. */
14 var parser = new ArgParser();
15 parser.addOption('port', abbr: 'p',
16 help: 'The main server port we wish to respond to requests.',
17 defaultsTo: '0');
18 parser.addOption('crossOriginPort', abbr: 'c',
19 help: 'A different port that accepts request from the main server port.',
20 defaultsTo: '0');
21 parser.addOption('mode', abbr: 'm', help: 'Testing mode.',
22 defaultsTo: 'release');
23 parser.addOption('arch', abbr: 'a', help: 'Testing architecture.',
24 defaultsTo: 'ia32');
25 parser.addFlag('help', abbr: 'h', negatable: false,
26 help: 'Print this usage information.');
27 var args = parser.parse(new Options().arguments);
28 if (args['help']) {
29 print(parser.getUsage());
30 } else {
31 // Pretend we're running test.dart so that TestUtils doesn't get confused
32 // about the "current directory." This is only used if we're trying to run
33 // this file independently for local testing.
34 TestUtils.testScriptPath = new Path(new Options().script)
35 .directoryPath
36 .join(new Path('../../test.dart'))
37 .canonicalize()
38 .toNativePath();
39 TestingServerRunner.setPackageRootDir({'mode': args['mode'],
40 'arch': args['arch'], 'system': Platform.operatingSystem,
41 'build_directory': ''});
42
43 TestingServerRunner.startHttpServer('127.0.0.1',
44 port: int.parse(args['port']));
45 print('Server listening on port '
46 '${TestingServerRunner.serverList[0].port}.');
47 TestingServerRunner.startHttpServer('127.0.0.1',
48 allowedPort: TestingServerRunner.serverList[0].port, port:
49 int.parse(args['crossOriginPort']));
50 print(
51 'Server listening on port ${TestingServerRunner.serverList[1].port}.');
52 }
53 }
11 /** 54 /**
12 * Runs a set of servers that are initialized specifically for the needs of our 55 * Runs a set of servers that are initialized specifically for the needs of our
13 * test framework, such as dealing with package-root. 56 * test framework, such as dealing with package-root.
14 */ 57 */
15 class TestingServerRunner { 58 class TestingServerRunner {
16 static List serverList = []; 59 static List serverList = [];
17 static Path _packageRootDir = null; 60 static Path _packageRootDir = null;
18 61
19 // Added as a getter so that the function will be called again each time the 62 // Added as a getter so that the function will be called again each time the
20 // default request handler closure is executed. 63 // default request handler closure is executed.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 }); 133 });
91 134
92 httpServer.listen(host, port); 135 httpServer.listen(host, port);
93 serverList.add(httpServer); 136 serverList.add(httpServer);
94 } 137 }
95 138
96 static terminateHttpServers() { 139 static terminateHttpServers() {
97 for (var server in serverList) server.close(); 140 for (var server in serverList) server.close();
98 } 141 }
99 } 142 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/temp_package_root/args/args.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698