[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ERT indentation testing
From: |
Ted Zlatanov |
Subject: |
Re: ERT indentation testing |
Date: |
Thu, 09 Jun 2011 11:05:34 -0500 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) |
On Wed, 08 Jun 2011 12:24:13 -0300 Stefan Monnier <address@hidden> wrote:
>> Is the patch above usable (using `find-file-noselect' as discussed)?
SM> I trust your judgment on it. The functionality is one I'd like to see,
SM> but I don't have time to check the actual code.
OK, great.
>> Should I keep working on this, commit it as is, or forget about it?
SM> If/when you think it's ready, please install it.
I'm concerned that it's failing a few tests. I think the files are
incorrect for the .rc and .sh content, don't know about the Prolog.
FAILED test-indent-2-prolog\.prolog
FAILED test-indent-3-shell\.rc
FAILED test-indent-4-shell\.sh
Third patch attached, just "make test-indent". If you think those tests
are legitimate failures, I'll commit, but otherwise I should fix them.
Thanks
Ted
=== modified file 'test/indent/Makefile'
--- test/indent/Makefile 2010-08-30 20:34:52 +0000
+++ test/indent/Makefile 2011-06-02 18:07:15 +0000
@@ -13,3 +13,6 @@
--eval '(indent-region (point-min) (point-max) nil)' \
--eval '(write-region (point-min) (point-max) "$<.new")'
diff -u -B $< $<.new
+
+test-indent:
+ $(EMACS) --batch -l ert -l test-indent.el -f
ert-run-tests-batch-and-exit
=== added file 'test/indent/test-indent.el'
--- test/indent/test-indent.el 1970-01-01 00:00:00 +0000
+++ test/indent/test-indent.el 2011-06-02 18:39:23 +0000
@@ -0,0 +1,67 @@
+;;; test-indent.el --- run indentation tests
+
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+
+;; Author: Ted Zlatanov <address@hidden>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; The purpose of this module is to verify that all the files in te
+;; current directory are indented correctly.
+
+;;; Code:
+
+(eval-when-compile
+ (require 'ert)
+ (require 'cl)
+
+ (defsubst test-indent-trim (string)
+ "Lose leading and trailing whitespace. Copied from BBDB."
+ (if (string-match "\\`[ \t\n]+" string)
+ (setq string (substring string (match-end 0))))
+ (if (string-match "[ \t\n]+\\'" string)
+ (setq string (substring string 0 (match-beginning 0))))
+ string)
+
+ (let ((files (delete "test-indent.el"
+ (directory-files "." nil "\\`[^.]+\\..+[a-zA-Z]\\'")))
+ f)
+ (loop for i from 1 to (length files)
+ for f = (nth (1- i) files)
+ do (eval `(ert-deftest ,(intern (format "test-indent-%d-%s" i f)) ()
+ (let ((lnum 0))
+ (message "Testing indentation of %s" ,f)
+ (set-buffer (find-file-noselect ,f))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (incf lnum)
+ (let* ((a (line-beginning-position))
+ (b (line-end-position))
+ (line (buffer-substring a b)))
+ (message "Testing indentation of %s:%05d: %s"
+ ,f lnum line)
+ (unless (or (string-match "KNOWN INDENT BUG" line)
+ (equal (test-indent-trim line) ""))
+ (indent-region a b nil)
+ (should (equal line (buffer-substring
+ (line-beginning-position)
+ (line-end-position)))))
+ (forward-line)))))))))
+
+(provide 'test-indent)
+;;; test-indent.el ends here
- Re: ERT indentation testing, (continued)
- Re: ERT indentation testing, Ted Zlatanov, 2011/06/03
- Re: ERT indentation testing, martin rudalics, 2011/06/03
- extra-interactive functions (was: ERT indentation testing), Ted Zlatanov, 2011/06/03
- Re: extra-interactive functions, martin rudalics, 2011/06/03
- Re: extra-interactive functions, Ted Zlatanov, 2011/06/03
- Re: extra-interactive functions, martin rudalics, 2011/06/03
- Re: extra-interactive functions, Ted Zlatanov, 2011/06/03
- Re: extra-interactive functions, martin rudalics, 2011/06/03
Re: ERT indentation testing, Ted Zlatanov, 2011/06/08
Re: ERT indentation testing, Alan Mackenzie, 2011/06/02