unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.)
@ 2018-05-22 22:55 Noam Postavsky
  2018-05-23  0:52 ` Finding macro-generated ert test definitions João Távora
  2018-05-23 14:54 ` Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Noam Postavsky @ 2018-05-22 22:55 UTC (permalink / raw)
  To: João Távora; +Cc: Alan Mackenzie, Tino Calancha, Emacs developers

On 22 May 2018 at 15:21, João Távora <joaotavora@gmail.com> wrote:

> Also M-x ert-find-test-other-window could have helped you, but it
> doesn't (brings me to the beginning of the file, which isn't helpful). I
> don't know why, does anyone?

It works by searching the source file for "(ert-deftest TEST-NAME",
but in this case TEST-NAME doesn't occur in the source, it's produced
at compile time by the define-electric-pair-test macro.

See ert--find-test-regexp and find-function-search-for-symbol.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions
  2018-05-22 22:55 Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Noam Postavsky
@ 2018-05-23  0:52 ` João Távora
  2018-05-23 14:54 ` Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: João Távora @ 2018-05-23  0:52 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Alan Mackenzie, Tino Calancha, Emacs developers

Noam Postavsky <npostavs@gmail.com> writes:

> On 22 May 2018 at 15:21, João Távora <joaotavora@gmail.com> wrote:
>
>> Also M-x ert-find-test-other-window could have helped you, but it
>> doesn't (brings me to the beginning of the file, which isn't helpful). I
>> don't know why, does anyone?
>
> It works by searching the source file for "(ert-deftest TEST-NAME",
> but in this case TEST-NAME doesn't occur in the source, it's produced
> at compile time by the define-electric-pair-test macro.
>
> See ert--find-test-regexp and find-function-search-for-symbol.
>
Oh. I naively thought that the byte-compiler was providing positional
hints to f-f-s-for-symbol, but it's just a text search:

from find-function-search-for-symbol:

  ;; `regexp' matches definitions using known forms like
  ;; `defun', or `defvar'.  But some functions/variables
  ;; are defined using special macros (or functions), so
  ;; if `regexp' can't find the definition, we look for
  ;; something of the form "(SOMETHING <symbol> ...)".
  ;; This fails to distinguish function definitions from
  ;; variable declarations (or even uses thereof), but is
  ;; a good pragmatic fallback.

(Had me fooled until now, so I guess it's not so bad)

João, wondering where in bytecomp.el this could be hooked up...



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.)
  2018-05-22 22:55 Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Noam Postavsky
  2018-05-23  0:52 ` Finding macro-generated ert test definitions João Távora
@ 2018-05-23 14:54 ` Eli Zaretskii
  2018-05-23 22:40   ` Noam Postavsky
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2018-05-23 14:54 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: acm, emacs-devel, joaotavora, tino.calancha

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Tue, 22 May 2018 18:55:27 -0400
> Cc: Alan Mackenzie <acm@muc.de>, Tino Calancha <tino.calancha@gmail.com>,
> 	Emacs developers <emacs-devel@gnu.org>
> 
> On 22 May 2018 at 15:21, João Távora <joaotavora@gmail.com> wrote:
> 
> > Also M-x ert-find-test-other-window could have helped you, but it
> > doesn't (brings me to the beginning of the file, which isn't helpful). I
> > don't know why, does anyone?
> 
> It works by searching the source file for "(ert-deftest TEST-NAME",
> but in this case TEST-NAME doesn't occur in the source, it's produced
> at compile time by the define-electric-pair-test macro.
> 
> See ert--find-test-regexp and find-function-search-for-symbol.

WIBNI this was described in ert.texi?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.)
  2018-05-23 14:54 ` Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Eli Zaretskii
@ 2018-05-23 22:40   ` Noam Postavsky
  2018-05-24 16:41     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Noam Postavsky @ 2018-05-23 22:40 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: Alan Mackenzie, Emacs developers, João Távora,
	Tino Calancha

On 23 May 2018 at 10:54, Eli Zaretskii <eliz@gnu.org> wrote:

>> > Also M-x ert-find-test-other-window could have helped you, but it
>> > doesn't (brings me to the beginning of the file, which isn't helpful). I
>> > don't know why, does anyone?
>>
>> It works by searching the source file for "(ert-deftest TEST-NAME",
>> but in this case TEST-NAME doesn't occur in the source, it's produced
>> at compile time by the define-electric-pair-test macro.
>>
>> See ert--find-test-regexp and find-function-search-for-symbol.
>
> WIBNI this was described in ert.texi?

It's mostly not ert-specific, although probably worth warning about
it. How's this?

--- i/doc/misc/ert.texi
+++ w/doc/misc/ert.texi
@@ -386,5 +386,10 @@ How to Write Tests

+@findex ert-find-test-other-window
 Just like @code{find-function} is only able to find where a function
 was defined if the function was loaded from a file, ERT is only able
-to find where a test was defined if the test was loaded from a file.
+to find where a test was defined (via
+@code{ert-find-test-other-window}) if the test was loaded from a file.
+Since this relies on a textual search of the source, it will likely
+fail if you use a macro which expands into the @code{ert-deftest}
+form, especially if the test name itself is absent from the source.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.)
  2018-05-23 22:40   ` Noam Postavsky
@ 2018-05-24 16:41     ` Eli Zaretskii
  2018-05-24 16:50       ` Finding macro-generated ert test definitions João Távora
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2018-05-24 16:41 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: acm, emacs-devel, joaotavora, tino.calancha

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Wed, 23 May 2018 18:40:24 -0400
> Cc: João Távora <joaotavora@gmail.com>, 
> 	Alan Mackenzie <acm@muc.de>, Tino Calancha <tino.calancha@gmail.com>, 
> 	Emacs developers <emacs-devel@gnu.org>
> 
> How's this?
> 
> --- i/doc/misc/ert.texi
> +++ w/doc/misc/ert.texi
> @@ -386,5 +386,10 @@ How to Write Tests
> 
> +@findex ert-find-test-other-window
>  Just like @code{find-function} is only able to find where a function
>  was defined if the function was loaded from a file, ERT is only able
> -to find where a test was defined if the test was loaded from a file.
> +to find where a test was defined (via
> +@code{ert-find-test-other-window}) if the test was loaded from a file.
> +Since this relies on a textual search of the source, it will likely
> +fail if you use a macro which expands into the @code{ert-deftest}
> +form, especially if the test name itself is absent from the source.

Looks like a good addition, thanks.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions
  2018-05-24 16:41     ` Eli Zaretskii
@ 2018-05-24 16:50       ` João Távora
  2018-05-24 22:34         ` Noam Postavsky
  0 siblings, 1 reply; 8+ messages in thread
From: João Távora @ 2018-05-24 16:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: acm, emacs-devel, Noam Postavsky, tino.calancha

Eli Zaretskii <eliz@gnu.org> writes:

>> +@code{ert-find-test-other-window}) if the test was loaded from a file.
>> +Since this relies on a textual search of the source, it will likely
>> +fail if you use a macro which expands into the @code{ert-deftest}
>> +form, especially if the test name itself is absent from the source.
>
> Looks like a good addition, thanks.

Nothing against this, but can anyone comment on the possiblity of
recording actual position information in bytecomp.el, so we wouldn't
have this limitation in the first place (and hence wouldn't need to
document it)?

João



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions
  2018-05-24 16:50       ` Finding macro-generated ert test definitions João Távora
@ 2018-05-24 22:34         ` Noam Postavsky
  2018-05-24 23:00           ` João Távora
  0 siblings, 1 reply; 8+ messages in thread
From: Noam Postavsky @ 2018-05-24 22:34 UTC (permalink / raw)
  To: João Távora
  Cc: Alan Mackenzie, Eli Zaretskii, Emacs developers, Tino Calancha

On 24 May 2018 at 12:50, João Távora <joaotavora@gmail.com> wrote:

> Nothing against this, but can anyone comment on the possiblity of
> recording actual position information in bytecomp.el, so we wouldn't
> have this limitation in the first place (and hence wouldn't need to
> document it)?

Considering Bug#24592, it seems a bit optimistic to expect useful
position information from the byte compiler.

I think Michael's suggesting about `definition-name' could help. That
seems like something that should be mentioned in the elisp manual too,
somewhere.

https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00628.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Finding macro-generated ert test definitions
  2018-05-24 22:34         ` Noam Postavsky
@ 2018-05-24 23:00           ` João Távora
  0 siblings, 0 replies; 8+ messages in thread
From: João Távora @ 2018-05-24 23:00 UTC (permalink / raw)
  To: Noam Postavsky
  Cc: Alan Mackenzie, Eli Zaretskii, Emacs developers, Tino Calancha

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

On Thu, May 24, 2018, 23:34 Noam Postavsky <npostavs@gmail.com> wrote:

> On 24 May 2018 at 12:50, João Távora <joaotavora@gmail.com> wrote:
>
> > Nothing against this, but can anyone comment on the possiblity of
> > recording actual position information in bytecomp.el, so we wouldn't
> > have this limitation in the first place (and hence wouldn't need to
> > document it)?
>
> Considering Bug#24592, it seems a bit optimistic to expect useful
> position information from the byte compiler


Doesn't seem like a huge showstopper though. That bug is about errors and
warnings, whereas we want the position of the containing top-level form
that originated the named function being compiled. That would be a
considerable improvement already.

I think Michael's suggesting about `definition-name' could help. That
> seems like something that should be mentioned in the elisp manual too,
> somewhere.
>


I didn't fully understand it yet, but I will try that too.

Thanks

[-- Attachment #2: Type: text/html, Size: 2133 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-05-24 23:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-22 22:55 Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Noam Postavsky
2018-05-23  0:52 ` Finding macro-generated ert test definitions João Távora
2018-05-23 14:54 ` Finding macro-generated ert test definitions (WAS: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Eli Zaretskii
2018-05-23 22:40   ` Noam Postavsky
2018-05-24 16:41     ` Eli Zaretskii
2018-05-24 16:50       ` Finding macro-generated ert test definitions João Távora
2018-05-24 22:34         ` Noam Postavsky
2018-05-24 23:00           ` João Távora

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).