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

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

Issue 2593913003: Make File.create() fail when a directory exists at the same path (Closed)
Patch Set: Fix test for Windows Created 3 years, 12 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 | « runtime/bin/file_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
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4 //
5 // Dart test program for testing file creation.
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import "package:expect/expect.dart";
11 import "package:path/path.dart";
12
13 testCreate() async {
14 Directory tmp = await Directory.systemTemp.createTemp('file_test_create');
15 Expect.isTrue(await tmp.exists());
16 String filePath = "${tmp.path}/foo";
17 File file = new File(filePath);
18 File createdFile = await file.create();
19 Expect.equals(file, createdFile);
20 Expect.isTrue(await createdFile.exists());
21 await tmp.delete(recursive: true);
22 }
23
24 testBadCreate() async {
25 Directory tmp = await Directory.systemTemp.createTemp('file_test_create');
26 Expect.isTrue(await tmp.exists());
27 Directory tmp2 = await tmp.createTemp('file_test_create');
28 Expect.isTrue(await tmp2.exists());
29 String badFilePath = tmp2.path;
30 File badFile = new File(badFilePath);
31 try {
32 await badFile.create();
33 Expect.fail('Should be unreachable');
34 } catch(e) {
35 Expect.isTrue(e is FileSystemException);
36 if (Platform.isWindows) {
37 Expect.isTrue(e.toString().contains('Access is denied'));
kasperl 2016/12/22 08:24:40 This is going to fail in non-English locales.
38 } else {
39 Expect.isTrue(e.toString().contains('Is a directory'));
40 }
41 }
42 await tmp.delete(recursive: true);
43 }
44
45 main() async {
46 await testCreate();
47 await testBadCreate();
48 }
OLDNEW
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698