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

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

Issue 2580133002: Fix directory existence query error (Closed)
Patch Set: Use ENOTDIR. Fix test Created 4 years 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 | « runtime/bin/directory_macos.cc ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Directory listing test. 5 // Directory listing test.
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:io"; 8 import "dart:io";
9 9
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 596
597 597
598 testRename() { 598 testRename() {
599 var temp1 = Directory.systemTemp.createTempSync('directory_test'); 599 var temp1 = Directory.systemTemp.createTempSync('directory_test');
600 var temp2 = Directory.systemTemp.createTempSync('directory_test'); 600 var temp2 = Directory.systemTemp.createTempSync('directory_test');
601 var temp3 = temp1.renameSync(temp2.path); 601 var temp3 = temp1.renameSync(temp2.path);
602 Expect.isFalse(temp1.existsSync()); 602 Expect.isFalse(temp1.existsSync());
603 Expect.isTrue(temp2.existsSync()); 603 Expect.isTrue(temp2.existsSync());
604 Expect.equals(temp3.path, temp2.path); 604 Expect.equals(temp3.path, temp2.path);
605 605
606 temp2.rename(temp1.path).then((temp4) { 606 var temp4 = temp2.renameSync(temp1.path);
607 Expect.isFalse(temp3.existsSync()); 607 Expect.isFalse(temp3.existsSync());
608 Expect.isFalse(temp2.existsSync()); 608 Expect.isFalse(temp2.existsSync());
609 Expect.isTrue(temp1.existsSync()); 609 Expect.isTrue(temp1.existsSync());
610 Expect.isTrue(temp4.existsSync()); 610 Expect.isTrue(temp4.existsSync());
611 Expect.equals(temp1.path, temp4.path); 611 Expect.equals(temp1.path, temp4.path);
612 temp1.deleteSync(recursive: true); 612
613 }); 613 String foo = '${temp4.path}/foo';
614 String bar = '${temp4.path}/bar';
615 new File(foo).createSync();
616 try {
617 new Directory(foo).renameSync(bar);
618 Expect.fail('Directory.rename should fail to rename a non-directory');
619 } catch (e) {
620 Expect.isTrue(e is FileSystemException);
621 if (Platform.isLinux || Platform.isMacOS) {
622 Expect.isTrue(e.osError.message.contains('Not a directory'));
623 }
624 }
625
626 temp1.deleteSync(recursive: true);
614 } 627 }
615 628
616 main() { 629 main() {
617 DirectoryTest.testMain(); 630 DirectoryTest.testMain();
618 NestedTempDirectoryTest.testMain(); 631 NestedTempDirectoryTest.testMain();
619 testCreateTempErrorSync(); 632 testCreateTempErrorSync();
620 testCreateTempError(); 633 testCreateTempError();
621 testCreateExistingSync(); 634 testCreateExistingSync();
622 testCreateExisting(); 635 testCreateExisting();
623 testCreateDirExistingFileSync(); 636 testCreateDirExistingFileSync();
624 testCreateDirExistingFile(); 637 testCreateDirExistingFile();
625 testRename(); 638 testRename();
626 } 639 }
OLDNEW
« no previous file with comments | « runtime/bin/directory_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698