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(); |