From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.bugs Subject: bug#18405: bug#28311: 25.2; Improve syntax highlighting in bat-mode Date: Fri, 22 Sep 2017 21:04:19 +0200 Message-ID: References: <87wp5jr100.fsf@Rainer.invalid> <83fubedf2f.fsf@gnu.org> <8epoaik6r4.fsf@fencepost.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c09470657298d0559cbe091" X-Trace: blaine.gmane.org 1506107117 22923 195.159.176.226 (22 Sep 2017 19:05:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 22 Sep 2017 19:05:17 +0000 (UTC) Cc: 28311@debbugs.gnu.org, Achim Gratz , 18405@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 22 21:05:09 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvTG9-0005ce-5F for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Sep 2017 21:05:09 +0200 Original-Received: from localhost ([::1]:60653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvTGG-0007it-HI for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Sep 2017 15:05:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvTG7-0007gq-7f for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2017 15:05:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvTG3-0002hz-1j for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2017 15:05:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44545) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvTG2-0002hE-Ub for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2017 15:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dvTG2-0003if-AL for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2017 15:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Anders Lindgren Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Sep 2017 19:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18405 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18405-submit@debbugs.gnu.org id=B18405.150610706914254 (code B ref 18405); Fri, 22 Sep 2017 19:05:02 +0000 Original-Received: (at 18405) by debbugs.gnu.org; 22 Sep 2017 19:04:29 +0000 Original-Received: from localhost ([127.0.0.1]:53226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvTFV-0003hl-2M for submit@debbugs.gnu.org; Fri, 22 Sep 2017 15:04:29 -0400 Original-Received: from mail-vk0-f46.google.com ([209.85.213.46]:44892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvTFS-0003hS-57; Fri, 22 Sep 2017 15:04:26 -0400 Original-Received: by mail-vk0-f46.google.com with SMTP id d12so1048148vkf.1; Fri, 22 Sep 2017 12:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LVl6parrpvP+hJWBXywN82VHiNDCCV0i1W/Vl9neEME=; b=sxZjIj7KET3v6IWBh+cMjYXw5GwIlHQjkHj92nj9jHlEq5dlPTjH1U6g3ix5sFN8D6 STYGV4ftqqouhgmBRtw2tdohJb2sm2wNL2Wif616F/N1C+6qD/JkTbu3wHh9ht/D8rIj 6yDW1+ohDNjDBJxhLiM4JXspZ10uYHxlKvZmEVaQzrP9V+zlZUnyS+Bq9fdB6Bv+o9Q2 ilvj6v6RECW8xhq4QSLLQD+VrmQVLGl8/kB3XwGkW0zeLmTEKhS8JiYHcljVPV21jqg/ ARSlqIVkhWkg5D5MFlhzyCvZjMh8H628tq3owqBGCrn8Zi7/TrfIVyQbk+PpngHtic1t dzfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LVl6parrpvP+hJWBXywN82VHiNDCCV0i1W/Vl9neEME=; b=VVweUPNU/ickNvVBJnZF8kk9c/CnrdK/JbaYozWKqjR9gZ49WUMIK9mmOqSAzE/6vU flYTiON4GkDxq4e0jFOvVwIDAzom9eo+WIkl24wh2X0oFkIgzq8oS20cHvxUwpRbMUuX Sjr/DGsvtSsjLz+gp64WU5s7r2PMmsivaomG6r9FO5lG+9G+JqpHtehWFb/KiR/ecBll aX+ixdKBvNuZJseIUzKz6nCDheuL5F4XZCSf4ZVwoZRHih0Uo90/n7o9E0sSYL/UD9Ao lm1l3Gz4hzL83LlrmDuo2AEiPLShKJ/eO4K22h5aGQ5y6scCYhF+cmo1LKeDXfyRQ5Im LWbg== X-Gm-Message-State: AHPjjUgbx4RFsJlvKDgNK/7wLsjeVrafs0JTwsa8hhS6DoIVKOMmnNIa 1oJGEmORQU7yERSOOwwQRXCHQLix9EHE5Vulpus= X-Google-Smtp-Source: AOwi7QBqTAJiCFr5qnu0znvUvjaG6RGdUzEFD1zQO0EHkZx0rPcBnAl/wOnju7irydAQINEghCfA1cVHnYSiTud93KM= X-Received: by 10.31.237.2 with SMTP id l2mr127289vkh.91.1506107060593; Fri, 22 Sep 2017 12:04:20 -0700 (PDT) Original-Received: by 10.31.171.202 with HTTP; Fri, 22 Sep 2017 12:04:19 -0700 (PDT) In-Reply-To: <8epoaik6r4.fsf@fencepost.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137250 Archived-At: --94eb2c09470657298d0559cbe091 Content-Type: text/plain; charset="UTF-8" Hi! Unfortunately, I can't comment on the actual error found, as I wasn't involved in the fix... Anyway, I am positively glad that you have tests for font-lock rules. However, using htmlfontify for this doesn't seem like the best tool for this. 1) The output of htmlfontify may change in the future, in which case you will need to rewrite all your tests, 2) HTML is hard to read, and 3) The ert explainer doesn't really help you here. If example, in this case all it tells you is that the resulting html strings have different lengths. On other words, it may work for snippets like this, but it would not scale well. A couple of years ago I wrote a tool, faceup (https://github.com/ Lindydancer/faceup), specifically for testing highlighting in Emacs using ert. It uses a simple markup language, so the result is easier to read than when using HTML. The reference text can be used inline (like in your test) or stored in a corresponding ".faceup" file, which makes it possible to test files thousands of lines long. When a test fails, the ert explainer will tell you which lines contained errors, what that lines contained, and what they should contain, so it's much easier to find errors. I have successfully used this is several of my font-lock packages. In addition, I've accumulated a number of source files in various programming languages in a regression test suite for font-lock (https://github.com/ Lindydancer/font-lock-regression-suite). If you would like to modernise your font-lock test, I would be happy to contribute it to Emacs (as I suggested in bug#16063). -- Anders On Fri, Sep 22, 2017 at 7:01 PM, Glenn Morris wrote: > > Running 5 tests (2017-09-22 09:57:54-0700) > passed 1/5 bat-test-fill-paragraph-comment > hfy batch mode ( *temp*-973592:bat-mode) > Test bat-test-fontification-iter-var-1 backtrace: > signal(ert-test-failed (((should (equal (bat-test-fontify "echo %%a\ > ert-fail(((should (equal (bat-test-fontify "echo %%a\necho %%~dp1\ne > (if (unwind-protect (setq value-17 (apply fn-15 args-16)) (setq form > (let (form-description-19) (if (unwind-protect (setq value-17 (apply > (let ((value-17 'ert-form-evaluation-aborted-18)) (let (form-descrip > (let* ((fn-15 (function equal)) (args-16 (condition-case err (let (( > (closure (t) nil (let* ((fn-15 (function equal)) (args-16 (condition > ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test > ert-run-test(#s(ert-test :name bat-test-fontification-iter-var-1 :do > ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test > ert-run-tests(t #f(compiled-function (event-type &rest event-args) # > ert-run-tests-batch(nil) > ert-run-tests-batch-and-exit(nil) > eval((ert-run-tests-batch-and-exit nil)) > command-line-1(("-L" ":." "-l" "ert" "-l" "lisp/progmodes/bat-mode-t > command-line() > normal-top-level() > Test bat-test-fontification-iter-var-1 condition: > (ert-test-failed > ((should > (equal > (bat-test-fontify "echo %%a > echo %%~dp1 > echo %%~$PATH:I") > "echo %% class=\"variable-name\">a > echo %%~dp1 span> > echo %%~$ class=\"variable-name\">PATH:I span>")) > :form > (equal > #("echo %% class=\"variable-name\">a > echo %%~dp1 span> > echo %%~$PATH:I" > 22 26 > (face font-lock-builtin-face) > 64 65 > (face font-lock-variable-name-face) > 95 99 > (face font-lock-builtin-face) > 137 141 > (face font-lock-variable-name-face) > 171 175 > (face font-lock-builtin-face) > 213 221 > (face font-lock-variable-name-face)) > "echo %% class=\"variable-name\">a > echo %%~dp1 span> > echo %%~$ class=\"variable-name\">PATH:I span>") > :value nil :explanation > (arrays-of-different-length 228 263 > #("echo > %%a > echo %%~dp1 span> > echo %%~$PATH:I" > 22 26 > (face font-lock-builtin-face) > 64 65 > (face font-lock-variable-name-face) > 95 99 > (face font-lock-builtin-face) > 137 141 > (face font-lock-variable-name-face) > 171 175 > (face font-lock-builtin-face) > 213 221 > (face font-lock-variable-name-face)) > "echo > %%a > echo %%~dp1 span> > echo %%~$ class=\"variable-name\">PATH:I" > first-mismatch-at 109))) > FAILED 2/5 bat-test-fontification-iter-var-1 > hfy batch mode ( *temp*-454955:bat-mode) > passed 3/5 bat-test-fontification-var-decl > hfy batch mode ( *temp*-493544:bat-mode) > passed 4/5 bat-test-fontification-var-delayed-exp > hfy batch mode ( *temp*-832943:bat-mode) > passed 5/5 bat-test-fontification-var-exp > > Ran 5 tests, 4 results as expected, 1 unexpected (2017-09-22 09:57:54-0700) > > 1 unexpected results: > FAILED bat-test-fontification-iter-var-1 > > --94eb2c09470657298d0559cbe091 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

Unfortunately, I can't comment = on the actual error found, as I wasn't involved in the fix...

Anyway, I am positively glad that you have tests for font-l= ock rules. However, using htmlfontify for this doesn't seem like the be= st tool for this. 1) The output of htmlfontify may change in the future, in= which case you will need to rewrite all your tests, 2) HTML is hard to rea= d, and 3) The ert explainer doesn't really help you here. If example, i= n this case all it tells you is that the resulting html strings have differ= ent lengths. On other words, it may work for snippets like this, but it wou= ld not scale well.

A couple of years ago I wrote a= tool, faceup (https://github.com/Lindydancer/faceup), specifically for t= esting highlighting in Emacs using ert. It uses a simple markup language, s= o the result is easier to read than when using HTML. The reference text can= be used inline (like in your test) or stored in a corresponding ".fac= eup" file, which makes it possible to test files thousands of lines lo= ng. When a test fails, the ert explainer will tell you which lines containe= d errors, what that lines contained, and what they should contain, so it= 9;s much easier to find errors. I have successfully used this is several of= my font-lock packages. In addition, I've accumulated a number of sourc= e files in various programming languages in a regression test suite for fon= t-lock (https://github.com/Lindydancer/font-lock-reg= ression-suite).

If you would like to modernise= your font-lock test, I would be happy to contribute it to Emacs (as I sugg= ested in bug#16063).

=C2=A0 =C2=A0 -- Anders
=

On Fri, Sep= 22, 2017 at 7:01 PM, Glenn Morris <rgm@gnu.org> wrote:

Running 5 tests (2017-09-22 09:57:54-0700)
=C2=A0 =C2=A0passed=C2=A0 1/5=C2=A0 bat-test-fill-paragraph-comment hfy batch mode ( *temp*-973592:bat-mode)
Test bat-test-fontification-iter-var-1 backtrace:
=C2=A0 signal(ert-test-failed (((should (equal (bat-test-fontify "echo= %%a\
=C2=A0 ert-fail(((should (equal (bat-test-fontify "echo %%a\necho %%~d= p1\ne
=C2=A0 (if (unwind-protect (setq value-17 (apply fn-15 args-16)) (setq form=
=C2=A0 (let (form-description-19) (if (unwind-protect (setq value-17 (apply=
=C2=A0 (let ((value-17 'ert-form-evaluation-aborted-18)) (let (for= m-descrip
=C2=A0 (let* ((fn-15 (function equal)) (args-16 (condition-case err (let ((=
=C2=A0 (closure (t) nil (let* ((fn-15 (function equal)) (args-16 (condition=
=C2=A0 ert--run-test-internal(#s(ert--test-execution-info :test #s(ert= -test
=C2=A0 ert-run-test(#s(ert-test :name bat-test-fontification-iter-var-= 1 :do
=C2=A0 ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-= test
=C2=A0 ert-run-tests(t #f(compiled-function (event-type &rest event-arg= s) #
=C2=A0 ert-run-tests-batch(nil)
=C2=A0 ert-run-tests-batch-and-exit(nil)
=C2=A0 eval((ert-run-tests-batch-and-exit nil))
=C2=A0 command-line-1(("-L" ":." "-l" "e= rt" "-l" "lisp/progmodes/bat-mode-t
=C2=A0 command-line()
=C2=A0 normal-top-level()
Test bat-test-fontification-iter-var-1 condition:
=C2=A0 =C2=A0 (ert-test-failed
=C2=A0 =C2=A0 =C2=A0((should
=C2=A0 =C2=A0 =C2=A0 =C2=A0(equal
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (bat-test-fontify "echo %%a
echo %%~dp1
echo %%~$PATH:I")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "<span class=3D\"builtin\">= ;echo</span> %%<span class=3D\"variable-name\">a</= span>
<span class=3D\"builtin\">echo</span> %%~dp<span c= lass=3D\"variable-name\">1</span>
<span class=3D\"builtin\">echo</span> %%~$<span cl= ass=3D\"variable-name\">PATH</span>:<span class= =3D\"variable-name\">I</span>"))
=C2=A0 =C2=A0 =C2=A0 :form
=C2=A0 =C2=A0 =C2=A0 (equal
=C2=A0 =C2=A0 =C2=A0 =C2=A0#("<span class=3D\"builtin\"&g= t;echo</span> %%<span class=3D\"variable-name\">a<= /span>
<span class=3D\"builtin\">echo</span> %%<span clas= s=3D\"variable-name\">~dp1</span>
<span class=3D\"builtin\">echo</span> %%<span clas= s=3D\"variable-name\">~$PATH:I</span>" 22 26 (face font-lock-builtin-face)
64 65
(face font-lock-variable-name-face)
95 99
(face font-lock-builtin-face)
137 141
(face font-lock-variable-name-face)
171 175
(face font-lock-builtin-face)
213 221
(face font-lock-variable-name-face))
=C2=A0 =C2=A0 =C2=A0 =C2=A0"<span class=3D\"builtin\">= echo</span> %%<span class=3D\"variable-name\">a</<= wbr>span>
<span class=3D\"builtin\">echo</span> %%~dp<span c= lass=3D\"variable-name\">1</span>
<span class=3D\"builtin\">echo</span> %%~$<span cl= ass=3D\"variable-name\">PATH</span>:<span class= =3D\"variable-name\">I</span>")
=C2=A0 =C2=A0 =C2=A0 :value nil :explanation
=C2=A0 =C2=A0 =C2=A0 (arrays-of-different-length 228 263
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #("<span class=3D\&qu= ot;builtin\">echo</span> %%<span class=3D\"variable-n= ame\">a</span>
<span class=3D\"builtin\">echo</span> %%<span clas= s=3D\"variable-name\">~dp1</span>
<span class=3D\"builtin\">echo</span> %%<span clas= s=3D\"variable-name\">~$PATH:I</span>" 22 26 (face font-lock-builtin-face)
64 65
(face font-lock-variable-name-face)
95 99
(face font-lock-builtin-face)
137 141
(face font-lock-variable-name-face)
171 175
(face font-lock-builtin-face)
213 221
(face font-lock-variable-name-face))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "<span class=3D\"= ;builtin\">echo</span> %%<span class=3D\"variable-nam= e\">a</span>
<span class=3D\"builtin\">echo</span> %%~dp<span c= lass=3D\"variable-name\">1</span>
<span class=3D\"builtin\">echo</span> %%~$<span cl= ass=3D\"variable-name\">PATH</span>:<span class= =3D\"variable-name\">I</span>" first-mismatch-= at 109)))
=C2=A0 =C2=A0FAILED=C2=A0 2/5=C2=A0 bat-test-fontification-iter-var-1<= br> hfy batch mode ( *temp*-454955:bat-mode)
=C2=A0 =C2=A0passed=C2=A0 3/5=C2=A0 bat-test-fontification-var-decl hfy batch mode ( *temp*-493544:bat-mode)
=C2=A0 =C2=A0passed=C2=A0 4/5=C2=A0 bat-test-fontification-var-delayed= -exp
hfy batch mode ( *temp*-832943:bat-mode)
=C2=A0 =C2=A0passed=C2=A0 5/5=C2=A0 bat-test-fontification-var-exp

Ran 5 tests, 4 results as expected, 1 unexpected (2017-09-22 09:57:54-0700)=

1 unexpected results:
=C2=A0 =C2=A0FAILED=C2=A0 bat-test-fontification-iter-var-1


--94eb2c09470657298d0559cbe091--