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

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

Issue 2441743002: Fix two io tests for precompilation, update status (Closed)
Patch Set: address comments Created 4 years, 2 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
« no previous file with comments | « no previous file | tests/standalone/io/stream_pipe_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
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 // OtherResources=readline_test1.dat
6 //
5 // VMOptions= 7 // VMOptions=
6 // VMOptions=--short_socket_read 8 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 9 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 10 // VMOptions=--short_socket_read --short_socket_write
9 11
10 library ServerTest; 12 library ServerTest;
11 13
12 import "package:expect/expect.dart"; 14 import "package:expect/expect.dart";
13 import "package:async_helper/async_helper.dart"; 15 import "package:async_helper/async_helper.dart";
14 import "dart:async"; 16 import "dart:async";
15 import "dart:io"; 17 import "dart:io";
16 import "dart:isolate"; 18 import "dart:isolate";
17 part "testing_server.dart"; 19 part "testing_server.dart";
18 20
19 21
20 String getDataFilename(String path) => 22 String getDataFilename(String path) =>
21 new File(path).existsSync() ? path : '../$path'; 23 Platform.script.resolve(path).toFilePath();
22 24
23 25
24 bool compareFileContent(String fileName1, String fileName2) { 26 bool compareFileContent(String fileName1, String fileName2) {
25 var contents1 = new File(fileName1).readAsStringSync(); 27 var contents1 = new File(fileName1).readAsStringSync();
26 var contents2 = new File(fileName2).readAsStringSync(); 28 var contents2 = new File(fileName2).readAsStringSync();
27 return contents1 == contents2; 29 return contents1 == contents2;
28 } 30 }
29 31
30 32
31 // This test does: 33 // This test does:
32 // 1. Opens a socket to the testing server. 34 // 1. Opens a socket to the testing server.
33 // 2. Pipes the content of a file to that sockets input stream. 35 // 2. Pipes the content of a file to that sockets input stream.
34 // 3. Creates a temp file. 36 // 3. Creates a temp file.
35 // 4. Pipes the socket output stream to the temp file. 37 // 4. Pipes the socket output stream to the temp file.
36 // 5. Expects the original file and the temp file to be equal. 38 // 5. Expects the original file and the temp file to be equal.
37 class PipeServerGame { 39 class PipeServerGame {
38 40
39 int count = 0; 41 int count = 0;
40 42
41 PipeServerGame.start() 43 PipeServerGame.start()
42 : _messages = 0 { 44 : _messages = 0 {
43 initialize(); 45 initialize();
44 } 46 }
45 47
46 void runTest() { 48 void runTest() {
47 49
48 void connectHandler() { 50 void connectHandler() {
49 String srcFileName = 51 String srcFileName =
50 getDataFilename("tests/standalone/io/readline_test1.dat"); 52 getDataFilename("readline_test1.dat");
51 Stream fileInput = new File(srcFileName).openRead(); 53 Stream fileInput = new File(srcFileName).openRead();
52 fileInput.pipe(_socket).then((_) { 54 fileInput.pipe(_socket).then((_) {
53 var tempDir = Directory.systemTemp.createTempSync('dart_pipe_server'); 55 var tempDir = Directory.systemTemp.createTempSync('dart_pipe_server');
54 var dstFileName = tempDir.path + "/readline_test1.dat"; 56 var dstFileName = tempDir.path + "/readline_test1.dat";
55 var dstFile = new File(dstFileName); 57 var dstFile = new File(dstFileName);
56 dstFile.createSync(); 58 dstFile.createSync();
57 var fileOutput = dstFile.openWrite(); 59 var fileOutput = dstFile.openWrite();
58 _socket.pipe(fileOutput).then((_) { 60 _socket.pipe(fileOutput).then((_) {
59 // Check that the resulting file is equal to the initial 61 // Check that the resulting file is equal to the initial
60 // file. 62 // file.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void onConnection(Socket connection) { 118 void onConnection(Socket connection) {
117 connection.pipe(connection); 119 connection.pipe(connection);
118 } 120 }
119 } 121 }
120 122
121 123
122 main() { 124 main() {
123 asyncStart(); 125 asyncStart();
124 PipeServerGame echoServerGame = new PipeServerGame.start(); 126 PipeServerGame echoServerGame = new PipeServerGame.start();
125 } 127 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/stream_pipe_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698