From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: ERT indentation testing Date: Thu, 09 Jun 2011 11:05:34 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87k4cvkn1t.fsf@lifelogs.com> References: <87pqngewwp.fsf@spindle.srvr.nix> <87pqnfu51p.fsf@spindle.srvr.nix> <87d3jf3ef8.fsf_-_@lifelogs.com> <87fwobasiy.fsf@lifelogs.com> <87mxi1qlwv.fsf@lifelogs.com> <874o48axbk.fsf@lifelogs.com> <874o40k3fz.fsf@lifelogs.com> Reply-To: emacs-devel@gnu.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1307636164 994 80.91.229.12 (9 Jun 2011 16:16:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Jun 2011 16:16:04 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 09 18:16:00 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QUhti-0005NP-Eo for ged-emacs-devel@m.gmane.org; Thu, 09 Jun 2011 18:15:54 +0200 Original-Received: from localhost ([::1]:43665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUhth-0003tb-4Z for ged-emacs-devel@m.gmane.org; Thu, 09 Jun 2011 12:15:53 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:45707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUhk3-0001H1-I3 for emacs-devel@gnu.org; Thu, 09 Jun 2011 12:05:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QUhk0-0008Od-BR for emacs-devel@gnu.org; Thu, 09 Jun 2011 12:05:54 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:57367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUhjz-0008O8-TE for emacs-devel@gnu.org; Thu, 09 Jun 2011 12:05:52 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QUhjx-0007Xl-J5 for emacs-devel@gnu.org; Thu, 09 Jun 2011 18:05:49 +0200 Original-Received: from c-67-186-102-106.hsd1.il.comcast.net ([67.186.102.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Jun 2011 18:05:49 +0200 Original-Received: from tzz by c-67-186-102-106.hsd1.il.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Jun 2011 18:05:49 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 118 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-67-186-102-106.hsd1.il.comcast.net X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Mail-Copies-To: never User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:d26jtasCkkjaqMC6fVqnomLuFFU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:140325 Archived-At: --=-=-= Content-Type: text/plain On Wed, 08 Jun 2011 12:24:13 -0300 Stefan Monnier 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=test-indent.patch === 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 + +;; 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 . + +;;; 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 --=-=-=--