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

Unified Diff: tests/standalone/src/FileTest.dart

Issue 9389002: Ensure FileTest.dart deletes temporary directories (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/FileTest.dart
diff --git a/tests/standalone/src/FileTest.dart b/tests/standalone/src/FileTest.dart
index 8ab586cd7d0415053a4a4c668437bb238bf23f95..5b172bb088e4ab0486d23dbaeb186e37c88ff67d 100644
--- a/tests/standalone/src/FileTest.dart
+++ b/tests/standalone/src/FileTest.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, 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.
//
@@ -11,7 +11,7 @@ class FileTest {
static int numLiveAsyncTests = 0;
static void asyncTestStarted() { ++numLiveAsyncTests; }
- static void asyncTestDone() {
+ static void asyncTestDone(String name) {
--numLiveAsyncTests;
if (numLiveAsyncTests == 0) {
deleteTempDirectory();
@@ -232,7 +232,7 @@ class FileTest {
file4.deleteHandler = () {
file4.existsHandler = (exists) {
Expect.isFalse(exists);
- asyncTestDone();
+ asyncTestDone("testReadWrite");
};
file4.exists();
};
@@ -293,32 +293,31 @@ class FileTest {
file.createSync();
List<int> buffer = content.charCodes();
OutputStream outStream = file.openOutputStream();
- outStream.closeHandler = () {
- File file2 = new File(filename);
- OutputStream appendingOutput = file2.openOutputStream(FileMode.APPEND);
- appendingOutput.write(buffer);
- appendingOutput.closeHandler = () {
- File file3 = new File(filename);
- file3.openHandler = (RandomAccessFile openedFile) {
- openedFile.lengthHandler = (int length) {
- Expect.equals(content.length * 2, length);
- openedFile.closeHandler = () {
- asyncTestDone();
- };
- openedFile.close();
+ outStream.write(buffer);
+ outStream.close();
ricow1 2012/02/13 11:40:45 how do we know that the output has been written to
Søren Gjesse 2012/02/13 11:58:04 Output streams are buffering streams which will fl
+ File file2 = new File(filename);
+ OutputStream appendingOutput = file2.openOutputStream(FileMode.APPEND);
+ appendingOutput.write(buffer);
+ appendingOutput.close();
+ File file3 = new File(filename);
+ file3.openHandler = (RandomAccessFile openedFile) {
+ openedFile.lengthHandler = (int length) {
+ Expect.equals(content.length * 2, length);
+ openedFile.closeHandler = () {
+ file3.deleteHandler = () {
+ asyncTestDone("testOutputStreamWriteAppend");
};
- openedFile.length();
+ file3.delete();
};
- file3.open();
+ openedFile.close();
};
- appendingOutput.close();
+ openedFile.length();
};
+ file3.open();
asyncTestStarted();
- outStream.write(buffer);
- outStream.close();
}
-
+
static void testReadWriteSync() {
// Read a file.
String inFilename = getFilename("tests/vm/data/fixed_length_file");
@@ -382,7 +381,7 @@ class FileTest {
Expect.isTrue(err.indexOf("failed") != -1);
openedFile.closeHandler = () {
file.deleteHandler = () {
- asyncTestDone();
+ asyncTestDone("testReadEmptyFile");
};
file.delete();
};
@@ -483,7 +482,7 @@ class FileTest {
file.deleteHandler = () {
file.existsHandler = (exists) {
Expect.isFalse(exists);
- asyncTestDone();
+ asyncTestDone("testTruncate");
};
file.exists();
};
@@ -754,7 +753,7 @@ class FileTest {
file.deleteHandler = () {
file.existsHandler = (exists) {
Expect.isFalse(exists);
- asyncTestDone();
+ asyncTestDone("testAppend");
};
file.exists();
};
@@ -810,7 +809,7 @@ class FileTest {
testPosition();
testPositionSync();
testMixedSyncAndAsync();
- asyncTestStarted();
+
createTempDirectory(() {
testReadWrite();
testReadWriteSync();
@@ -826,7 +825,6 @@ class FileTest {
testAppendSync();
testWriteAppend();
testOutputStreamWriteAppend();
- asyncTestDone();
});
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698