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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/testing/dart/temp_package_root/path/path.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/http_server.dart
diff --git a/tools/testing/dart/http_server.dart b/tools/testing/dart/http_server.dart
index db2d04642c28395ccf0eaf0b6eba7ebd8aae325e..dcc37a6dbb03dba3abc1257d60c58fa882b6e7f6 100644
--- a/tools/testing/dart/http_server.dart
+++ b/tools/testing/dart/http_server.dart
@@ -7,7 +7,53 @@ library http_server;
import 'dart:io';
import 'dart:isolate';
import 'test_suite.dart'; // For TestUtils.
+// TODO(efortuna): Rewrite to not use the args library and simply take an
+// expected number of arguments, so test.dart doesn't rely on the args library?
+// See discussion on https://codereview.chromium.org/11931025/.
+import 'vendored_pkg/args/args.dart';
+main() {
+ /** Convenience method for local testing. */
+ var parser = new ArgParser();
+ parser.addOption('port', abbr: 'p',
+ help: 'The main server port we wish to respond to requests.',
+ defaultsTo: '0');
+ parser.addOption('crossOriginPort', abbr: 'c',
+ help: 'A different port that accepts request from the main server port.',
+ defaultsTo: '0');
+ parser.addOption('mode', abbr: 'm', help: 'Testing mode.',
+ defaultsTo: 'release');
+ parser.addOption('arch', abbr: 'a', help: 'Testing architecture.',
+ defaultsTo: 'ia32');
+ parser.addFlag('help', abbr: 'h', negatable: false,
+ help: 'Print this usage information.');
+ var args = parser.parse(new Options().arguments);
+ if (args['help']) {
+ print(parser.getUsage());
+ } else {
+ // Pretend we're running test.dart so that TestUtils doesn't get confused
+ // about the "current directory." This is only used if we're trying to run
+ // this file independently for local testing.
+ TestUtils.testScriptPath = new Path(new Options().script)
+ .directoryPath
+ .join(new Path('../../test.dart'))
+ .canonicalize()
+ .toNativePath();
+ TestingServerRunner.setPackageRootDir({'mode': args['mode'],
+ 'arch': args['arch'], 'system': Platform.operatingSystem,
+ 'build_directory': ''});
+
+ TestingServerRunner.startHttpServer('127.0.0.1',
+ port: int.parse(args['port']));
+ print('Server listening on port '
+ '${TestingServerRunner.serverList[0].port}.');
+ TestingServerRunner.startHttpServer('127.0.0.1',
+ allowedPort: TestingServerRunner.serverList[0].port, port:
+ int.parse(args['crossOriginPort']));
+ print(
+ 'Server listening on port ${TestingServerRunner.serverList[1].port}.');
+ }
+}
/**
* Runs a set of servers that are initialized specifically for the needs of our
* test framework, such as dealing with package-root.
« no previous file with comments | « no previous file | tools/testing/dart/temp_package_root/path/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698