OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 const int NUM_SERVERS = 10; | 10 const int NUM_SERVERS = 10; |
(...skipping 18 matching lines...) Expand all Loading... |
29 server.listen((request) { | 29 server.listen((request) { |
30 request.pipe(request); | 30 request.pipe(request); |
31 }); | 31 }); |
32 return server; | 32 return server; |
33 }); | 33 }); |
34 } | 34 } |
35 | 35 |
36 Future runClientProcess(int port) { | 36 Future runClientProcess(int port) { |
37 return Process.run(Platform.executable, | 37 return Process.run(Platform.executable, |
38 []..addAll(Platform.executableArguments) | 38 []..addAll(Platform.executableArguments) |
39 ..add(Platform.script.toFilePath()) | 39 ..add(Platform.script) |
40 ..add('--client') | 40 ..add('--client') |
41 ..add(port.toString())).then((ProcessResult result) { | 41 ..add(port.toString())).then((ProcessResult result) { |
42 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { | 42 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { |
43 print("Client failed, exit code ${result.exitCode}"); | 43 print("Client failed, exit code ${result.exitCode}"); |
44 print(" stdout:"); | 44 print(" stdout:"); |
45 print(result.stdout); | 45 print(result.stdout); |
46 print(" stderr:"); | 46 print(" stderr:"); |
47 print(result.stderr); | 47 print(result.stderr); |
48 Expect.fail('Client subprocess exit code: ${result.exitCode}'); | 48 Expect.fail('Client subprocess exit code: ${result.exitCode}'); |
49 } | 49 } |
50 }); | 50 }); |
51 } | 51 } |
52 | 52 |
53 runClient(int port) { | 53 runClient(int port) { |
54 Socket.connect(InternetAddress.LOOPBACK_IP_V4, port).then((connection) { | 54 Socket.connect(InternetAddress.LOOPBACK_IP_V4, port).then((connection) { |
55 connection.listen((_) { }, onDone: () => print('SUCCESS')); | 55 connection.listen((_) { }, onDone: () => print('SUCCESS')); |
56 connection.close(); | 56 connection.close(); |
57 }); | 57 }); |
58 } | 58 } |
OLD | NEW |