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, 02 Jun 2011 13:43:27 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <874o48axbk.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> 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 1307041223 23713 80.91.229.12 (2 Jun 2011 19:00:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Jun 2011 19:00:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 02 21:00:19 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 1QSD7x-0001yk-8b for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2011 21:00:17 +0200 Original-Received: from localhost ([::1]:36371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSD7w-00012h-06 for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2011 15:00:16 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSCrx-0005Sm-GV for emacs-devel@gnu.org; Thu, 02 Jun 2011 14:43:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSCrv-0006uR-MD for emacs-devel@gnu.org; Thu, 02 Jun 2011 14:43:45 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:47226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSCrv-0006uL-5D for emacs-devel@gnu.org; Thu, 02 Jun 2011 14:43:43 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QSCrr-0002Fs-A0 for emacs-devel@gnu.org; Thu, 02 Jun 2011 20:43:39 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Jun 2011 20:43:39 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Jun 2011 20:43:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 112 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 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:GVVTFKrPvsh9wnv9rk2QiHsN/8g= 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:140091 Archived-At: --=-=-= Content-Type: text/plain On Wed, 01 Jun 2011 16:30:56 -0500 Ted Zlatanov wrote: TZ> See the attached patch to make the indentation testing use ERT and TZ> operate on any files with a "." in the name except test-indent.el. Second patch: TZ> The test fails on modula2.mod and I'm not sure why. I am setting TZ> `enable-local-variables'. Is it because I'm going line by line? Or TZ> something with the line boundaries? Uses `find-file' to process the local variables correctly. TZ> Should the test stop when any file fails or keep going? One test is created per file now, and any one file won't block the other tests. 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) + (find-file ,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 --=-=-=--