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. |