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

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

Issue 25471003: Modify tests to use Directory.systemTemp (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
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 // 'fuzz' test the file APIs by providing unexpected type arguments. The test 5 // 'fuzz' test the file APIs by providing unexpected type arguments. The test
6 // passes if the VM does not crash. 6 // passes if the VM does not crash.
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 futures.add(doItAsync(() => f.readAsString(encoding: v2))); 57 futures.add(doItAsync(() => f.readAsString(encoding: v2)));
58 futures.add(doItAsync(() => f.readAsLines(encoding: v2))); 58 futures.add(doItAsync(() => f.readAsLines(encoding: v2)));
59 }); 59 });
60 }); 60 });
61 }); 61 });
62 Future.wait(futures).then((_) => asyncEnd()); 62 Future.wait(futures).then((_) => asyncEnd());
63 } 63 }
64 64
65 65
66 fuzzSyncRandomAccessMethods() { 66 fuzzSyncRandomAccessMethods() {
67 var d = new Directory(''); 67 var temp = Directory.systemTemp.createTempSync('dart_file_fuzz');
68 var temp = d.createTempSync();
69 var file = new File('${temp.path}/x'); 68 var file = new File('${temp.path}/x');
70 file.createSync(); 69 file.createSync();
71 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ]; 70 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ];
72 for (var m in modes) { 71 for (var m in modes) {
73 var opened = file.openSync(mode: m); 72 var opened = file.openSync(mode: m);
74 typeMapping.forEach((k, v) { 73 typeMapping.forEach((k, v) {
75 doItSync(() => opened.setPositionSync(v)); 74 doItSync(() => opened.setPositionSync(v));
76 doItSync(() => opened.truncateSync(v)); 75 doItSync(() => opened.truncateSync(v));
77 doItSync(() => opened.writeByteSync(v)); 76 doItSync(() => opened.writeByteSync(v));
78 }); 77 });
79 for (var p in typePermutations(2)) { 78 for (var p in typePermutations(2)) {
80 doItSync(() => opened.writeStringSync(p[0], encoding: p[1])); 79 doItSync(() => opened.writeStringSync(p[0], encoding: p[1]));
81 } 80 }
82 for (var p in typePermutations(3)) { 81 for (var p in typePermutations(3)) {
83 doItSync(() => opened.readIntoSync(p[0], p[1], p[2])); 82 doItSync(() => opened.readIntoSync(p[0], p[1], p[2]));
84 doItSync(() => opened.writeFromSync(p[0], p[1], p[2])); 83 doItSync(() => opened.writeFromSync(p[0], p[1], p[2]));
85 } 84 }
86 opened.closeSync(); 85 opened.closeSync();
87 } 86 }
88 temp.deleteSync(recursive: true); 87 temp.deleteSync(recursive: true);
89 } 88 }
90 89
91 fuzzAsyncRandomAccessMethods() { 90 fuzzAsyncRandomAccessMethods() {
92 var d = new Directory(''); 91 var d = new Directory('');
93 var temp = d.createTempSync(); 92 var temp = Directory.systemTemp.createTempSync('dart_file_fuzz');
94 var file = new File('${temp.path}/x'); 93 var file = new File('${temp.path}/x');
95 file.createSync(); 94 file.createSync();
96 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ]; 95 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ];
97 var futures = []; 96 var futures = [];
98 var openedFiles = []; 97 var openedFiles = [];
99 for (var m in modes) { 98 for (var m in modes) {
100 var opened = file.openSync(mode: m); 99 var opened = file.openSync(mode: m);
101 openedFiles.add(opened); 100 openedFiles.add(opened);
102 typeMapping.forEach((k, v) { 101 typeMapping.forEach((k, v) {
103 futures.add(doItAsync(() => opened.setPosition(v))); 102 futures.add(doItAsync(() => opened.setPosition(v)));
(...skipping 15 matching lines...) Expand all
119 temp.deleteSync(recursive: true); 118 temp.deleteSync(recursive: true);
120 }); 119 });
121 } 120 }
122 121
123 main() { 122 main() {
124 fuzzSyncMethods(); 123 fuzzSyncMethods();
125 fuzzAsyncMethods(); 124 fuzzAsyncMethods();
126 fuzzSyncRandomAccessMethods(); 125 fuzzSyncRandomAccessMethods();
127 fuzzAsyncRandomAccessMethods(); 126 fuzzAsyncRandomAccessMethods();
128 } 127 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_error_test.dart ('k') | tests/standalone/io/file_input_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698