unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: ERT indentation testing
Date: Wed, 01 Jun 2011 16:30:56 -0500	[thread overview]
Message-ID: <87mxi1qlwv.fsf@lifelogs.com> (raw)
In-Reply-To: jwvmxiizz24.fsf-monnier+emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

On Thu, 19 May 2011 08:56:07 -0300 Stefan Monnier <monnier@iro.umontreal.ca> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test-indent.patch --]
[-- Type: text/x-diff, Size: 2729 bytes --]

=== 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 <tzz@lifelogs.com>
+
+;; 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))
+
+(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


  reply	other threads:[~2011-06-01 21:30 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 23:21 [RFC PATCH] setting indentation styles via `c-file-style' fails to actually change indentation Nix
2011-05-18  0:17 ` Stefan Monnier
2011-05-18 20:28   ` Nix
2011-05-18 21:08     ` ERT indentation testing (was: [RFC PATCH] setting indentation styles via `c-file-style' fails to actually change indentation) Ted Zlatanov
2011-05-18 22:19       ` ERT indentation testing Stefan Monnier
2011-05-19 10:33         ` Ted Zlatanov
2011-05-19 11:56           ` Stefan Monnier
2011-06-01 21:30             ` Ted Zlatanov [this message]
2011-06-02 18:43               ` Ted Zlatanov
2011-06-03  0:04                 ` Stefan Monnier
2011-06-03 11:33                   ` Ted Zlatanov
2011-06-03 12:12                     ` martin rudalics
2011-06-03 15:06                       ` extra-interactive functions (was: ERT indentation testing) Ted Zlatanov
2011-06-03 15:27                         ` extra-interactive functions martin rudalics
2011-06-03 16:11                           ` Ted Zlatanov
2011-06-03 18:59                             ` martin rudalics
2011-06-03 19:10                               ` Ted Zlatanov
2011-06-03 20:54                                 ` martin rudalics
2011-06-08 10:44                 ` ERT indentation testing Ted Zlatanov
2011-06-08 15:24                   ` Stefan Monnier
2011-06-09 16:05                     ` Ted Zlatanov
2011-06-10 20:41                       ` Stefan Monnier
2011-06-01 14:31   ` [RFC PATCH] setting indentation styles via `c-file-style' fails to actually change indentation Nix
2011-06-02 12:24     ` Alan Mackenzie
2011-06-02 13:35       ` Stefan Monnier
2011-06-02 16:47       ` Nix
2011-06-02 21:15         ` Alan Mackenzie
2011-06-02 21:43           ` Nix
2011-06-05 15:06             ` Alan Mackenzie
2011-07-24 10:07               ` Kan-Ru Chen
2011-08-05 14:14               ` Nix
2011-05-18  3:27 ` Glenn Morris
2011-05-18 11:02   ` Juanma Barranquero
  -- strict thread matches above, loose matches on Subject: below --
2011-06-02 12:37 ERT indentation testing Alan Mackenzie
2011-06-02 14:23 ` Ted Zlatanov
2011-06-03 11:48   ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mxi1qlwv.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).