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

Unified Diff: test/io_test.dart

Issue 850953004: Don't touch files whose contents do not change. Fix #127. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Update changelog. Created 5 years, 11 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/io.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 530536ec519ce41cdb67ba410caa5f2b0adee27c..c3281899d29d97e44e6f83d47a15b87bae14da94 100644
--- a/test/io_test.dart
+++ b/test/io_test.dart
@@ -4,6 +4,7 @@
library dart_style.test.io;
+import 'dart:async';
import 'dart:io';
import 'package:dart_style/src/io.dart';
@@ -51,6 +52,41 @@ void main() {
]).validate();
});
+ test("doesn't touch unchanged files", () {
+ d.dir('code', [
+ d.file('bad.dart', _SOURCE),
+ d.file('good.dart', _FORMATTED),
+ ]).create();
+
+ modTime(String file) {
+ return new File(p.join(d.defaultRoot, 'code', file)).statSync().modified;
+ }
+
+ var badBefore;
+ var goodBefore;
+
+ schedule(() {
+ badBefore = modTime('bad.dart');
+ goodBefore = modTime('good.dart');
+
+ // Wait a bit so the mod time of a formatted file will be different.
+ return new Future.delayed(new Duration(seconds: 1));
+ });
+
+ schedule(() {
+ var dir = new Directory(p.join(d.defaultRoot, 'code'));
+ processDirectory(dir, overwrite: true);
+
+ // Should be touched.
+ var badAfter = modTime('bad.dart');
+ expect(badAfter, isNot(equals(badBefore)));
+
+ // Should not be touched.
+ var goodAfter = modTime('good.dart');
+ expect(goodAfter, equals(goodBefore));
+ });
+ });
+
test("doesn't follow directory symlinks by default", () {
d.dir('code', [
d.file('a.dart', _SOURCE),
« no previous file with comments | « lib/src/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698