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

Side by Side Diff: tests/standalone/io/http_cross_process_test.dart

Issue 23414004: Add dart:io tests for creating a client and server in separate processes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | tests/standalone/io/raw_socket_cross_process_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
6 import "package:expect/expect.dart";
7 import 'dart:async';
8 import 'dart:io';
9
10 const int NUM_SERVERS = 10;
11
12 void main() {
13 var args = new Options().arguments;
14 if (args.isEmpty) {
15 for (int i = 0; i < NUM_SERVERS; ++i) {
16 makeServer().then((server) {
17 runClientProcess(server.port).then((_) => server.close());
18 });
19 }
20 } else if (args[0] == 'client') {
21 int port = int.parse(args[1]);
22 runClient(port);
23 } else {
24 Expect.fail('Unknown arguments to http_cross_process_test.dart');
25 }
26 }
27
28 Future makeServer() {
29 return HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) {
30 server.listen((request) {
31 request.pipe(request.response);
32 });
33 return server;
34 });
35 }
36
37 Future runClientProcess(int port) {
38 return Process.run(Platform.executable,
39 []..addAll(Platform.executableArguments)
40 ..add(Platform.script)
41 ..add('client')
Søren Gjesse 2013/08/26 09:25:58 Should it be --client ? (for all tests)
42 ..add(port.toString())).then((ProcessResult result) {
43 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) {
44 print("Client failed, exit code ${result.exitCode}");
45 print(" stdout:");
46 print(result.stdout);
47 print(" stderr:");
48 print(result.stderr);
49 Expect.fail('Client subprocess exit code: ${result.exitCode}');
50 }
51 });
52 }
53
54 runClient(int port) {
55 var client = new HttpClient();
56 client.get(InternetAddress.LOOPBACK_IP_V4, port, "/")
57 .then((request) => request.close())
58 .then((response) => response.listen((data) {},
59 onDone: () => print('SUCCESS')));
60 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/raw_socket_cross_process_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698