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: Wed, 01 Jun 2011 16:30:56 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87mxi1qlwv.fsf@lifelogs.com> References: <87pqngewwp.fsf@spindle.srvr.nix> <87pqnfu51p.fsf@spindle.srvr.nix> <87d3jf3ef8.fsf_-_@lifelogs.com> <87fwobasiy.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 1306964374 25504 80.91.229.12 (1 Jun 2011 21:39:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 1 Jun 2011 21:39:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 01 23:39:29 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 1QRt8R-000869-S2 for ged-emacs-devel@m.gmane.org; Wed, 01 Jun 2011 23:39:28 +0200 Original-Received: from localhost ([::1]:52572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRt8Q-0003wf-Rh for ged-emacs-devel@m.gmane.org; Wed, 01 Jun 2011 17:39:27 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:55684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRt0S-0001lq-P6 for emacs-devel@gnu.org; Wed, 01 Jun 2011 17:31:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRt0Q-0007D0-By for emacs-devel@gnu.org; Wed, 01 Jun 2011 17:31:12 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:46948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRt0P-0007CP-N5 for emacs-devel@gnu.org; Wed, 01 Jun 2011 17:31:09 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QRt0N-0004a9-4w for emacs-devel@gnu.org; Wed, 01 Jun 2011 23:31:07 +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 ; Wed, 01 Jun 2011 23:31:07 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jun 2011 23:31:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 116 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:rU5ZCITNi1aRbD2NJRuoePqfWcQ= 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:140035 Archived-At: --=-=-= Content-Type: text/plain On Thu, 19 May 2011 08:56:07 -0300 Stefan Monnier wrote: >>>> This can be done with ERT, right? A bunch of .cc files with file-local >>>> variables could be indented "properly" for those variables. Then the >>>> test logic for each file is SM> [...] >>>> Plus, of course, it's not limited to .cc files. It would work just as >>>> well for .c, .pl, .el, whatever. SM> Yup, we already have such files in test/indent. >> Yes, I see that now (I didn't see the commit for those, cool!) >> We should have .c and .cc files with the major indentation styles >> specified as file-local variables, plus .ini, Perl, Java, Python, and of >> course Lisp (CL and ELisp). Should I add those? SM> Feel free. I only added the ones I actually worked on. BTW, the SM> octave.m testcase is too long for that kind of test (although the length SM> was instrumental in fixing some performance bugs). See the attached patch to make the indentation testing use ERT and operate on any files with a "." in the name except test-indent.el. The test fails on modula2.mod and I'm not sure why. I am setting `enable-local-variables'. Is it because I'm going line by line? Or something with the line boundaries? Should the test stop when any file fails or keep going? 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-01 20:48:21 +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-01 21:28:07 +0000 @@ -0,0 +1,57 @@ +;;; 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)) + +(ert-deftest test-indent-all () + (let ((enable-local-variables :all) + lnum) + (loop for f in (delete "test-indent.el" + (directory-files "." nil "^[^.]+\\.")) + do (with-temp-buffer + (message "Testing indentation of %s" f) + (insert-file-contents f) + (goto-char (point-min)) + (setq lnum 0) + (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 (string-match "KNOWN INDENT BUG" 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 --=-=-=--