]> Cypherpunks repositories - gostls13.git/commitdiff
misc/emacs: Detect stale coverage reports
authorAaron France <aaron.l.france@gmail.com>
Mon, 19 Aug 2013 20:32:00 +0000 (16:32 -0400)
committerAlan Donovan <adonovan@google.com>
Mon, 19 Aug 2013 20:32:00 +0000 (16:32 -0400)
When the coverage report file is older than the file we're
showing the coverage report for, then we show a simple message
to state this fact.

R=adonovan, dominik.honnef, bradfitz
CC=golang-dev
https://golang.org/cl/12919044

misc/emacs/go-mode.el

index 88a66364fa0817b8e28e8cbf807247d2440c5206..82c6e621fe094465dcaf43792cfbb6827ffd2fff 100644 (file)
@@ -1110,7 +1110,13 @@ for."
          (coverage-file (or coverage-file (go--coverage-file)))
          (ranges-and-divisor (go--coverage-parse-file
                               coverage-file
-                              (file-name-nondirectory (buffer-file-name origin-buffer)))))
+                              (file-name-nondirectory (buffer-file-name origin-buffer))))
+         (cov-mtime (nth 5 (file-attributes coverage-file)))
+         (cur-mtime (nth 5 (file-attributes (buffer-file-name origin-buffer)))))
+
+    (if (< (float-time cov-mtime) (float-time cur-mtime))
+        (message "Coverage file is older than the source file."))
+
     (with-current-buffer (or (get-buffer gocov-buffer-name)
                              (make-indirect-buffer origin-buffer gocov-buffer-name t))
       (set (make-local-variable 'go--coverage-origin-buffer) origin-buffer)