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

Unified Diff: test/io_test.dart

Issue 2192883003: Gracefully handle IO errors when failing to overwrite a file. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/formatter_options.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/io_test.dart
diff --git a/test/io_test.dart b/test/io_test.dart
index 695dd4de60fb8889d9190b051e94519e878f92c8..1f8f011dd0393f2dc77d79282821f94413ff2645 100644
--- a/test/io_test.dart
+++ b/test/io_test.dart
@@ -34,7 +34,9 @@ void main() {
processDirectory(overwriteOptions, dir);
}, 'Run formatter.');
- d.dir('code.dart', [d.file('a.dart', formattedSource)]).validate();
+ d.dir('code.dart', [
+ d.file('a.dart', formattedSource),
+ ]).validate();
});
test("doesn't touch unchanged files", () {
@@ -155,6 +157,24 @@ void main() {
});
if (!Platform.isWindows) {
+ // TODO(rnystrom): Figure out Windows equivalent of chmod and get this
+ // test running on Windows too.
+ test("reports error if file can not be written", () {
+ d.file('a.dart', unformattedSource).create();
+
+ schedule(() {
+ Process.runSync("chmod", ["-w", p.join(d.defaultRoot, 'a.dart')]);
+ }, 'Make file read-only.');
+
+ schedule(() {
+ var file = new File(p.join(d.defaultRoot, 'a.dart'));
+ processFile(overwriteOptions, file);
+ }, 'Run formatter.');
+
+ // Should not have been formatted.
+ d.file('a.dart', unformattedSource).validate();
+ });
+
test("doesn't follow file symlinks by default", () {
d.dir('code').create();
d.file('target_file.dart', unformattedSource).create();
« no previous file with comments | « lib/src/formatter_options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698