|
| 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 |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:test_runner/src/configuration.dart'; |
| 6 | +import 'package:test_runner/src/testing_servers.dart'; |
| 7 | +import 'package:test_runner/src/utils.dart'; |
| 8 | +import 'package:test_runner/src/vendored_pkg/args/args.dart'; |
| 9 | + |
| 10 | +void main(List<String> arguments) { |
| 11 | + var parser = new ArgParser(); |
| 12 | + parser.addOption('port', |
| 13 | + abbr: 'p', |
| 14 | + help: 'The main server port we wish to respond to requests.', |
| 15 | + defaultsTo: '0'); |
| 16 | + parser.addOption('crossOriginPort', |
| 17 | + abbr: 'c', |
| 18 | + help: 'A different port that accepts request from the main server port.', |
| 19 | + defaultsTo: '0'); |
| 20 | + parser.addFlag('help', |
| 21 | + abbr: 'h', negatable: false, help: 'Print this usage information.'); |
| 22 | + parser.addOption('build-directory', help: 'The build directory to use.'); |
| 23 | + parser.addOption('package-root', help: 'The package root to use.'); |
| 24 | + parser.addOption('packages', help: 'The package spec file to use.'); |
| 25 | + parser.addOption('network', |
| 26 | + help: 'The network interface to use.', defaultsTo: '0.0.0.0'); |
| 27 | + parser.addFlag('csp', |
| 28 | + help: 'Use Content Security Policy restrictions.', defaultsTo: false); |
| 29 | + parser.addOption('runtime', |
| 30 | + help: 'The runtime we are using (for csp flags).', defaultsTo: 'none'); |
| 31 | + |
| 32 | + var args = parser.parse(arguments); |
| 33 | + if (args['help'] as bool) { |
| 34 | + print(parser.getUsage()); |
| 35 | + } else { |
| 36 | + var servers = new TestingServers( |
| 37 | + args['build-directory'] as String, |
| 38 | + args['csp'] as bool, |
| 39 | + Runtime.find(args['runtime'] as String), |
| 40 | + null, |
| 41 | + args['package-root'] as String, |
| 42 | + args['packages'] as String); |
| 43 | + var port = int.parse(args['port'] as String); |
| 44 | + var crossOriginPort = int.parse(args['crossOriginPort'] as String); |
| 45 | + servers |
| 46 | + .startServers(args['network'] as String, |
| 47 | + port: port, crossOriginPort: crossOriginPort) |
| 48 | + .then((_) { |
| 49 | + DebugLogger.info('Server listening on port ${servers.port}'); |
| 50 | + DebugLogger.info('Server listening on port ${servers.crossOriginPort}'); |
| 51 | + }); |
| 52 | + } |
| 53 | +} |
0 commit comments