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

Unified 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, 4 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 | tests/standalone/io/raw_socket_cross_process_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_cross_process_test.dart
diff --git a/tests/standalone/io/http_cross_process_test.dart b/tests/standalone/io/http_cross_process_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..257ad313bbc8cedb51e03c8ed18af384cd345bd5
--- /dev/null
+++ b/tests/standalone/io/http_cross_process_test.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+
+import "package:expect/expect.dart";
+import 'dart:async';
+import 'dart:io';
+
+const int NUM_SERVERS = 10;
+
+void main() {
+ var args = new Options().arguments;
+ if (args.isEmpty) {
+ for (int i = 0; i < NUM_SERVERS; ++i) {
+ makeServer().then((server) {
+ runClientProcess(server.port).then((_) => server.close());
+ });
+ }
+ } else if (args[0] == 'client') {
+ int port = int.parse(args[1]);
+ runClient(port);
+ } else {
+ Expect.fail('Unknown arguments to http_cross_process_test.dart');
+ }
+}
+
+Future makeServer() {
+ return HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) {
+ server.listen((request) {
+ request.pipe(request.response);
+ });
+ return server;
+ });
+}
+
+Future runClientProcess(int port) {
+ return Process.run(Platform.executable,
+ []..addAll(Platform.executableArguments)
+ ..add(Platform.script)
+ ..add('client')
Søren Gjesse 2013/08/26 09:25:58 Should it be --client ? (for all tests)
+ ..add(port.toString())).then((ProcessResult result) {
+ if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) {
+ print("Client failed, exit code ${result.exitCode}");
+ print(" stdout:");
+ print(result.stdout);
+ print(" stderr:");
+ print(result.stderr);
+ Expect.fail('Client subprocess exit code: ${result.exitCode}');
+ }
+ });
+}
+
+runClient(int port) {
+ var client = new HttpClient();
+ client.get(InternetAddress.LOOPBACK_IP_V4, port, "/")
+ .then((request) => request.close())
+ .then((response) => response.listen((data) {},
+ onDone: () => print('SUCCESS')));
+}
« 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