| Index: tests/standalone/src/io/FileErrorTest.dart
|
| diff --git a/tests/standalone/src/io/FileErrorTest.dart b/tests/standalone/src/io/FileErrorTest.dart
|
| index 388420583563aee8f76ee8c6c89ea0acb058bdbe..e4e9575bee5d2acc4d464f10c44d3a8ab8511bcc 100644
|
| --- a/tests/standalone/src/io/FileErrorTest.dart
|
| +++ b/tests/standalone/src/io/FileErrorTest.dart
|
| @@ -14,10 +14,10 @@ Directory tempDir() {
|
| }
|
|
|
|
|
| -bool checkOpenNonExistentFileException(e) {
|
| +bool checkNonExistentFileException(e, str) {
|
| Expect.isTrue(e is FileIOException);
|
| Expect.isTrue(e.osError != null);
|
| - Expect.isTrue(e.toString().indexOf("Cannot open file") != -1);
|
| + Expect.isTrue(e.toString().indexOf(str) != -1);
|
| Platform platform = new Platform();
|
| if (platform.operatingSystem() == "linux") {
|
| Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
|
| @@ -34,6 +34,22 @@ bool checkOpenNonExistentFileException(e) {
|
| return true;
|
| }
|
|
|
| +
|
| +bool checkOpenNonExistentFileException(e) {
|
| + return checkNonExistentFileException(e, "Cannot open file");
|
| +}
|
| +
|
| +
|
| +bool checkDeleteNonExistentFileException(e) {
|
| + return checkNonExistentFileException(e, "Cannot delete file");
|
| +}
|
| +
|
| +
|
| +bool checkLengthNonExistentFileException(e) {
|
| + return checkNonExistentFileException(e, "Cannot retrieve length for file");
|
| +}
|
| +
|
| +
|
| void testOpenNonExistent() {
|
| Directory temp = tempDir();
|
| ReceivePort p = new ReceivePort();
|
| @@ -54,25 +70,6 @@ void testOpenNonExistent() {
|
| };
|
| }
|
|
|
| -bool checkDeleteNonExistentFileException(e) {
|
| - Expect.isTrue(e is FileIOException);
|
| - Expect.isTrue(e.osError != null);
|
| - Expect.isTrue(e.toString().indexOf("Cannot delete file") != -1);
|
| - Platform platform = new Platform();
|
| - if (platform.operatingSystem() == "linux") {
|
| - Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
|
| - } else if (platform.operatingSystem() == "macos") {
|
| - Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
|
| - } else if (platform.operatingSystem() == "windows") {
|
| - Expect.isTrue(
|
| - e.toString().indexOf(
|
| - "The system cannot find the file specified") != -1);
|
| - }
|
| - // File not not found has error code 2 on all supported platforms.
|
| - Expect.equals(2, e.osError.errorCode);
|
| -
|
| - return true;
|
| -}
|
|
|
| void testDeleteNonExistent() {
|
| Directory temp = tempDir();
|
| @@ -94,6 +91,28 @@ void testDeleteNonExistent() {
|
| };
|
| }
|
|
|
| +
|
| +void testLengthNonExistent() {
|
| + Directory temp = tempDir();
|
| + ReceivePort p = new ReceivePort();
|
| + p.receive((x, y) {
|
| + p.close();
|
| + temp.deleteRecursivelySync();
|
| + });
|
| + var file = new File("${temp.path}/nonExistentFile");
|
| +
|
| + // Non-existing file should throw exception.
|
| + Expect.throws(() => file.lengthSync(),
|
| + (e) => checkLengthNonExistentFileException(e));
|
| +
|
| + file.length((len) => Expect.fail("Unreachable code"));
|
| + file.onError = (e) {
|
| + checkLengthNonExistentFileException(e);
|
| + p.toSendPort().send(null);
|
| + };
|
| +}
|
| +
|
| +
|
| bool checkCreateInNonExistentDirectoryException(e) {
|
| Expect.isTrue(e is FileIOException);
|
| Expect.isTrue(e.osError != null);
|
| @@ -432,6 +451,7 @@ testOperateOnClosedFile() {
|
| main() {
|
| testOpenNonExistent();
|
| testDeleteNonExistent();
|
| + testLengthNonExistent();
|
| testCreateInNonExistentDirectory();
|
| testFullPathOnNonExistentDirectory();
|
| testDirectoryInNonExistentDirectory();
|
|
|