Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f424f3a

Browse files
aamcommit-bot@chromium.org
authored andcommitted
[vm/gardening] Fix file_fuzz_test so it doesn't create files in the dart sdk checkout root.
Fixes dart-lang/sdk#46737 TEST=Ensure file_fuzz_test doesn't create 'a' file Change-Id: I200bc63a86f75e0b770f1a2240a9e2bfdc99aef6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208285 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
1 parent babfe05 commit f424f3a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tests/standalone/io/file_fuzz_test.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import 'fuzz_support.dart';
1414
import "package:async_helper/async_helper.dart";
1515

1616
fuzzSyncMethods() {
17+
var temp = Directory.systemTemp.createTempSync('dart_file_fuzz');
1718
typeMapping.forEach((k, v) {
1819
File? file;
19-
doItSync(() => file = new File(v as String));
20+
doItSync(() => file = new File('${temp.path}/${v as String}'));
2021
if (file == null) return;
2122
final f = file!;
2223
doItSync(f.existsSync);
@@ -36,14 +37,16 @@ fuzzSyncMethods() {
3637
doItSync(() => f.readAsLinesSync(encoding: v2 as Encoding));
3738
});
3839
});
40+
temp.deleteSync(recursive: true);
3941
}
4042

4143
fuzzAsyncMethods() {
4244
asyncStart();
4345
var futures = <Future>[];
46+
var temp = Directory.systemTemp.createTempSync('dart_file_fuzz');
4447
typeMapping.forEach((k, v) {
4548
File? file;
46-
doItSync(() => file = new File(v as String));
49+
doItSync(() => file = new File('${temp.path}/${v as String}'));
4750
if (file == null) return;
4851
final f = file!;
4952
futures.add(doItAsync(f.exists));
@@ -62,7 +65,10 @@ fuzzAsyncMethods() {
6265
futures.add(doItAsync(() => f.readAsLines(encoding: v2 as Encoding)));
6366
});
6467
});
65-
Future.wait(futures).then((_) => asyncEnd());
68+
Future.wait(futures).then((_) {
69+
temp.deleteSync(recursive: true);
70+
asyncEnd();
71+
});
6672
}
6773

6874
fuzzSyncRandomAccessMethods() {

tests/standalone_2/io/file_fuzz_test.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import 'fuzz_support.dart';
1515
import "package:async_helper/async_helper.dart";
1616

1717
fuzzSyncMethods() {
18+
var temp = Directory.systemTemp.createTempSync('dart_file_fuzz');
1819
typeMapping.forEach((k, v) {
1920
File f;
20-
doItSync(() => f = new File(v));
21+
doItSync(() => f = new File('${temp.path}/$v'));
2122
if (f == null) return;
2223
doItSync(f.existsSync);
2324
doItSync(f.createSync);
@@ -36,14 +37,16 @@ fuzzSyncMethods() {
3637
doItSync(() => f.readAsLinesSync(encoding: v2));
3738
});
3839
});
40+
temp.deleteSync(recursive: true);
3941
}
4042

4143
fuzzAsyncMethods() {
4244
asyncStart();
4345
var futures = <Future>[];
46+
var temp = Directory.systemTemp.createTempSync('dart_file_fuzz');
4447
typeMapping.forEach((k, v) {
4548
File f;
46-
doItSync(() => f = new File(v));
49+
doItSync(() => f = new File('${temp.path}/$v'));
4750
if (f == null) return;
4851
futures.add(doItAsync(f.exists));
4952
futures.add(doItAsync(f.delete));
@@ -61,7 +64,10 @@ fuzzAsyncMethods() {
6164
futures.add(doItAsync(() => f.readAsLines(encoding: v2)));
6265
});
6366
});
64-
Future.wait(futures).then((_) => asyncEnd());
67+
Future.wait(futures).then((_) {
68+
temp.deleteSync(recursive: true);
69+
asyncEnd();
70+
});
6571
}
6672

6773
fuzzSyncRandomAccessMethods() {

0 commit comments

Comments
 (0)