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

Side by Side Diff: tests/standalone/io/stream_pipe_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 | « tests/standalone/io/pipe_server_test.dart ('k') | tests/standalone/standalone.status » ('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 import "dart:io"; 12 import "dart:io";
11 13
12 import "package:async_helper/async_helper.dart"; 14 import "package:async_helper/async_helper.dart";
13 import "package:expect/expect.dart"; 15 import "package:expect/expect.dart";
14 16
15 // Helper method to be able to run the test from the runtime 17 // Helper method to be able to run the test from the runtime
16 // directory, or the top directory. 18 // directory, or the top directory.
17 String getDataFilename(String path) => 19 String getDataFilename(String path) =>
18 new File(path).existsSync() ? path : '../$path'; 20 Platform.script.resolve(path).toFilePath();
19 21
20 22
21 bool compareFileContent(String fileName1, 23 bool compareFileContent(String fileName1,
22 String fileName2, 24 String fileName2,
23 {int file1Offset: 0, 25 {int file1Offset: 0,
24 int file2Offset: 0, 26 int file2Offset: 0,
25 int count}) { 27 int count}) {
26 var file1 = new File(fileName1).openSync(); 28 var file1 = new File(fileName1).openSync();
27 var file2 = new File(fileName2).openSync(); 29 var file2 = new File(fileName2).openSync();
28 var length1 = file1.lengthSync(); 30 var length1 = file1.lengthSync();
(...skipping 28 matching lines...) Expand all
57 59
58 60
59 // Test piping from one file to another and closing both streams 61 // Test piping from one file to another and closing both streams
60 // after wards. 62 // after wards.
61 testFileToFilePipe1() { 63 testFileToFilePipe1() {
62 // Force test to timeout if one of the handlers is 64 // Force test to timeout if one of the handlers is
63 // not called. 65 // not called.
64 asyncStart(); 66 asyncStart();
65 67
66 String srcFileName = 68 String srcFileName =
67 getDataFilename("tests/standalone/io/readline_test1.dat"); 69 getDataFilename("readline_test1.dat");
68 var srcStream = new File(srcFileName).openRead(); 70 var srcStream = new File(srcFileName).openRead();
69 71
70 var tempDir = Directory.systemTemp.createTempSync('dart_stream_pipe'); 72 var tempDir = Directory.systemTemp.createTempSync('dart_stream_pipe');
71 String dstFileName = tempDir.path + "/readline_test1.dat"; 73 String dstFileName = tempDir.path + "/readline_test1.dat";
72 new File(dstFileName).createSync(); 74 new File(dstFileName).createSync();
73 var output = new File(dstFileName).openWrite(); 75 var output = new File(dstFileName).openWrite();
74 srcStream.pipe(output).then((_) { 76 srcStream.pipe(output).then((_) {
75 bool result = compareFileContent(srcFileName, dstFileName); 77 bool result = compareFileContent(srcFileName, dstFileName);
76 new File(dstFileName).deleteSync(); 78 new File(dstFileName).deleteSync();
77 tempDir.deleteSync(); 79 tempDir.deleteSync();
78 Expect.isTrue(result); 80 Expect.isTrue(result);
79 asyncEnd(); 81 asyncEnd();
80 }); 82 });
81 } 83 }
82 84
83 85
84 // Test piping from one file to another and write additional data to 86 // Test piping from one file to another and write additional data to
85 // the output stream after piping finished. 87 // the output stream after piping finished.
86 testFileToFilePipe2() { 88 testFileToFilePipe2() {
87 // Force test to timeout if one of the handlers is 89 // Force test to timeout if one of the handlers is
88 // not called. 90 // not called.
89 asyncStart(); 91 asyncStart();
90 92
91 String srcFileName = 93 String srcFileName =
92 getDataFilename("tests/standalone/io/readline_test1.dat"); 94 getDataFilename("readline_test1.dat");
93 var srcFile = new File(srcFileName); 95 var srcFile = new File(srcFileName);
94 var srcStream = srcFile.openRead(); 96 var srcStream = srcFile.openRead();
95 97
96 var tempDir = Directory.systemTemp.createTempSync('dart_stream_pipe'); 98 var tempDir = Directory.systemTemp.createTempSync('dart_stream_pipe');
97 var dstFileName = tempDir.path + "/readline_test1.dat"; 99 var dstFileName = tempDir.path + "/readline_test1.dat";
98 var dstFile = new File(dstFileName); 100 var dstFile = new File(dstFileName);
99 dstFile.createSync(); 101 dstFile.createSync();
100 var output = dstFile.openWrite(); 102 var output = dstFile.openWrite();
101 output.addStream(srcStream).then((_) { 103 output.addStream(srcStream).then((_) {
102 output.add([32]); 104 output.add([32]);
(...skipping 21 matching lines...) Expand all
124 } 126 }
125 127
126 128
127 // Test piping two copies of one file to another. 129 // Test piping two copies of one file to another.
128 testFileToFilePipe3() { 130 testFileToFilePipe3() {
129 // Force test to timeout if one of the handlers is 131 // Force test to timeout if one of the handlers is
130 // not called. 132 // not called.
131 asyncStart(); 133 asyncStart();
132 134
133 String srcFileName = 135 String srcFileName =
134 getDataFilename("tests/standalone/io/readline_test1.dat"); 136 getDataFilename("readline_test1.dat");
135 var srcFile = new File(srcFileName); 137 var srcFile = new File(srcFileName);
136 var srcStream = srcFile.openRead(); 138 var srcStream = srcFile.openRead();
137 139
138 var tempDir = Directory.systemTemp.createTempSync('dart_stream_pipe'); 140 var tempDir = Directory.systemTemp.createTempSync('dart_stream_pipe');
139 var dstFileName = tempDir.path + "/readline_test1.dat"; 141 var dstFileName = tempDir.path + "/readline_test1.dat";
140 var dstFile = new File(dstFileName); 142 var dstFile = new File(dstFileName);
141 dstFile.createSync(); 143 dstFile.createSync();
142 var output = dstFile.openWrite(); 144 var output = dstFile.openWrite();
143 output.addStream(srcStream).then((_) { 145 output.addStream(srcStream).then((_) {
144 var srcStream2 = srcFile.openRead(); 146 var srcStream2 = srcFile.openRead();
(...skipping 21 matching lines...) Expand all
166 }); 168 });
167 }); 169 });
168 } 170 }
169 171
170 172
171 main() { 173 main() {
172 testFileToFilePipe1(); 174 testFileToFilePipe1();
173 testFileToFilePipe2(); 175 testFileToFilePipe2();
174 testFileToFilePipe3(); 176 testFileToFilePipe3();
175 } 177 }
OLDNEW
« no previous file with comments | « tests/standalone/io/pipe_server_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698