From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Troy Brown Newsgroups: gmane.emacs.bugs Subject: bug#69714: 30.0.50; ert-font-lock doesn't handle list of faces Date: Wed, 13 Mar 2024 12:14:38 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3615"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69714@debbugs.gnu.org To: Vladimir Kazanov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 13 17:15:52 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkRGh-0000lW-Lp for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Mar 2024 17:15:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkRGT-0004TE-N9; Wed, 13 Mar 2024 12:15:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkRGL-0004T1-Kx for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 12:15:30 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkRGJ-0006ws-OD for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 12:15:28 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rkRGs-0005va-KJ for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 12:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Troy Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Mar 2024 16:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69714 X-GNU-PR-Package: emacs Original-Received: via spool by 69714-submit@debbugs.gnu.org id=B69714.171034653522748 (code B ref 69714); Wed, 13 Mar 2024 16:16:02 +0000 Original-Received: (at 69714) by debbugs.gnu.org; 13 Mar 2024 16:15:35 +0000 Original-Received: from localhost ([127.0.0.1]:47195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkRGQ-0005uq-QW for submit@debbugs.gnu.org; Wed, 13 Mar 2024 12:15:35 -0400 Original-Received: from mail-ed1-f43.google.com ([209.85.208.43]:48163) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkRGO-0005uW-8T for 69714@debbugs.gnu.org; Wed, 13 Mar 2024 12:15:32 -0400 Original-Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5684ea117a3so1035a12.0 for <69714@debbugs.gnu.org>; Wed, 13 Mar 2024 09:14:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710346491; x=1710951291; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YZ5UZbkPvDsKWeb8+ZwNmPVdA0T/FrIWJeg9UF6GTwE=; b=xPmDElIhZ6XN4XKp1gvFjJVIqQQTntu2fWDe+UociDAXu5STycCVxy9/T+b2M18pnm V2UT5emWHzV/cIjK3/q4+9E9OsTRGtntA3aUEfMJSKGx7qGwYwfJyJ/PG8SGk2Ir9yBq SDb7mmCmxK/IsCo+9l1G2FNYyXC4lTqVCf733RZXpCS23QmOPeWf2UQeSNfnFWW+tHHg hWjSHab14rCyRdYQGom761DWeEuiqlOEmTlOZ8F6+dE7NGAFC7e31JCWGaHWEBLTeV5m 2n7eZCP4olm5vEbbm6z1nkppRmPTqFzZaZnnMzrA10VVQ0dFrwx29/tuLY/9sAHXj3Fa NIuA== X-Gm-Message-State: AOJu0YzibIkCsJjdcmcxJyxz8s4joS1CVB5dooCEnA+C32HyP9ldS1VW cLd44/GrqDQIlKviDTEn9S/ZenUf/2bJ5ZmxTvzHnuk8pP5pzz9m12anPCCiGC9oyg== X-Google-Smtp-Source: AGHT+IE+ZidWWC+rkmsNQ0YTrHNmxSUftWeut2fNi5NQv85s1EhcWNDzOUOBn1oujz/b6OHdvq9mPg== X-Received: by 2002:a50:8a98:0:b0:565:9e16:60da with SMTP id j24-20020a508a98000000b005659e1660damr2940299edj.30.1710346490773; Wed, 13 Mar 2024 09:14:50 -0700 (PDT) Original-Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com. [209.85.218.51]) by smtp.gmail.com with ESMTPSA id u7-20020aa7d0c7000000b005689a4b250fsm6924edo.48.2024.03.13.09.14.50 for <69714@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Mar 2024 09:14:50 -0700 (PDT) Original-Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a4429c556efso3946066b.0 for <69714@debbugs.gnu.org>; Wed, 13 Mar 2024 09:14:50 -0700 (PDT) X-Received: by 2002:a17:906:2b51:b0:a45:aef0:c449 with SMTP id b17-20020a1709062b5100b00a45aef0c449mr2393055ejg.39.1710346489986; Wed, 13 Mar 2024 09:14:49 -0700 (PDT) In-Reply-To: X-Gmail-Original-Message-ID: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281553 Archived-At: Hi Vlad, sorry for the delayed response. I haven't pushed my change which uses this package yet, as I was struggling to get it working and didn't want to push failing tests. I just discovered the package and was working on a regression test for a bug fix involving font locking. This seemed like the perfect reason to use your package. At the moment I only have this one work-in-progress test, but I expect to use it more going forward. I did check out your patch and for my immediate needs, it worked perfectly. Thanks! Additionally, I did experiment a little with the multi-caret functionality, which is nice as I have a use for that. I also experimented with the negation functionality (although I don't have an immediate need for that), and did notice a couple things. The first was that the assertion would be ignored if there was a space between the negation symbol and the face. Also, if the actual and expected faces didn't match and the negation flag was being used, it acted like the negation was not indicated at all and failed the test. I've included a diff below containing the changes I made which seemed to address those concerns. diff --git a/lisp/emacs-lisp/ert-font-lock.el b/lisp/emacs-lisp/ert-font-lo= ck.el index 06c90add9d3..1a5fe96fb09 100644 --- a/lisp/emacs-lisp/ert-font-lock.el +++ b/lisp/emacs-lisp/ert-font-lock.el @@ -61,6 +61,7 @@ ert-font-lock--assertion-line-re (group (zero-or-more (seq "^" (zero-or-more whitespace)))) ;; optional negation of the face specification (group (optional "!")) + (zero-or-more whitespace) ;; face symbol name or a list of symbols (group (or (regexp ert-font-lock--face-symbol-re) (regexp ert-font-lock--face-symbol-list-re)))) @@ -354,7 +355,7 @@ ert-font-lock--check-faces (when (symbolp expected-face) (setq expected-face (list expected-face))) - (when (not (equal actual-face expected-face)) + (when (and (not negation) (not (equal actual-face expected-face))) (ert-fail (list (format "Expected face %S, got %S on line %d column %d" expected-face actual-face line-checked column-check= ed) Thanks, Troy. On Tue, Mar 12, 2024 at 4:47=E2=80=AFPM Vladimir Kazanov wrote: > > Hi, > > I've attached a patch that handles face lists, fails on files without > assertions and expands the parser a bit to support multiple carets per > line. > > For faces it does the following: > > 1. Turn symbols into single element lists. > 2. Parses face lists from the assertions. > 3. Compare face lists using equas. > > Could you please check if this works for you? > > Thanks > > On Mon, 11 Mar 2024 at 08:36, Vladimir Kazanov wrot= e: > > > > Hi, > > > > Thanks for reporting this! I have a bunch of ert-font-lock > > improvements in my local repo getting ready for submission, and can > > look into your suggestions as well. > > > > Do you have your unit test code somewhere in a public repo? It'd be > > great to think of further improvements to support your use case. > > > > Thanks, > > Vlad > > > > On Sun, 10 Mar 2024 at 20:33, Troy Brown wrote: > > > > > > I'm trying to use this package to test out my tree-sitter mode, but a= m > > > running into an issue with lists of faces. It's possible that the > > > face for a location in the buffer will contain a list of 1 or more > > > faces. For example, when I use the ":override 'prepend" keyword in > > > the call to treesit-font-lock-rules, even if only a single face is > > > specified for the rule that matches that section of the buffer, this > > > will result in a list of one entry (i.e., "(face-name)"). > > > > > > When this happens, ert-font-lock fails to recognize that this matches > > > the face "face-name" (e.g., "^ face-name" will fail to match in this > > > case). I feel the tool should recognize a list containing a single > > > face as matching the face. Even worse however, it appears > > > ert-font-lock doesn't support a list of faces in the comment. I trie= d > > > to work around the original issue by using "^ (face-name)", but the > > > tool silently ignores this, as it doesn't match the internal regular > > > expression (which ended up allowing my test to pass without actually > > > checking anything). > > > > > > I can't figure out a way to use this tool in its current state due to > > > its lack of support for a list of faces. Also, I find that since it > > > silently ignores incorrect comment syntax (e.g., "^face-name", "^ > > > (face-name)"), it gives a false illusion that it's actually performin= g > > > those checks (and the checks are passing), when it's really just > > > ignoring them. Maybe any comment line starting with a "^" or "<-" > > > should be considered an assertion check and to fail if the rest of th= e > > > syntax is not as expected. Maybe it should also fail the test if no > > > assertion checks are found in a source file or string. > > > > > > Even if the tool would allow a list of a single face to match the > > > supplied face in the comment, I think it should also allow for > > > multiple faces to be listed in the comment. I have other places wher= e > > > multiple faces are used (e.g., "(font-lock-constant-face > > > font-lock-variable-name-face)" to highlight a constant variable), > > > which would not be testable with the current state of the package. > > > > > > > > > > > > > > > -- > > Regards, > > > > Vladimir Kazanov > > > > -- > Regards, > > Vladimir Kazanov