emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: [babel] Trying to add ERT test cases
Date: Tue, 20 Sep 2011 09:22:12 +0200	[thread overview]
Message-ID: <80d3evy8yj.fsf@somewhere.org> (raw)
In-Reply-To: <87litkte08.fsf@gmail.com>

Hi Eric,

Eric Schulte wrote:
>> * Test
>> #+begin_src emacs-lisp
>> (ert-deftest ob-tangle/speed-command-r ()
>>   "Test that speed command `r' does demote the headline."
>>   (org-test-at-id "4ee368b8-cf7c-4269-98c0-b28dcf94ff2b"
>>     (goto-char (point-at-bol))
>>     (org-self-insert-command ?r)
>>     (goto-char (point-at-bol))
>>     (should (looking-at "\\*\\* Speed command"))
>>     (delete-char 1)))
>> #+end_src
>> When running the test _once_, I get my level-1 headline preceded by 114
>> occurrences of ^M (yes, 114 for 1 test run!):
>> ^M^M^M...^M^M^M* Speed command (this must be at level-1 headline)
>> and no demotion of my headline.
>> Do you understand such?
> So it looks like these self-insert-command functions are special cases.
> They don't look to their arguments to see what key-press invoked them,
> but rather they call the `this-command-keys' function for this purpose.
> We can force the behavior we want by overriding the definition of this
> function locally, taking this approach the following test case worked
> for me
> #+begin_src emacs-lisp
>   (ert-deftest ob-tangle/speed-command-r ()
>     "Test that speed command `r' does demote the headline."
>     (org-test-with-temp-text "* Speed command"
>       (flet ((this-command-keys () "r")) (org-self-insert-command ?r))
>       (goto-char (point-min))
>       (should (looking-at "\\*\\* Speed command"))))
> #+end_src

It passes!  So does:

#+begin_src emacs-lisp
  (ert-deftest ob-tangle/speed-command-r ()
    "Test that speed command `r' does demote the headline."
    (org-test-with-temp-text "* Speed command"
      (flet ((this-command-keys () "r")) (org-self-insert-command ?a))
      (goto-char (point-min))
      (should (looking-at "\\*\\* Speed command"))))

where the argument of `org-self-insert-command' is `a' (could be anything, it
seems). Very weird.

I just understood as well why I got 114 ^M: 114 is the ASCII code for `r', and
`\r' is as well ^M -- though `r' is not...

>> [...] I read thru the page you link to. Just a minor thing: link to "See
>> ert-publish-test.el for the implementation" is broken.
>> Do you have a solution for checking against internal broken links?
> Nothing comes immediately to mind.
>> I still have my idea of letting DOT draw an graph of the
>> interconnection between pages, so that we see missing pages, and
>> unreachable ones (files on the file system, but never linked). I
>> should (find the time to) extend it enough to serve that purpose.
> This could be useful, like a site map for worg.  As an intermediate step
> I could see it being useful to simply print out all internal links whose
> target does not exist on the file system.

I'll try to come up with something (in Babel) soon.

Best regards,

Sebastien Vauban

  reply	other threads:[~2011-09-20  7:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 11:20 Sebastien Vauban
2011-09-19 14:35 ` Eric Schulte
2011-09-19 19:35   ` Sebastien Vauban
2011-09-19 21:32     ` Eric Schulte
2011-09-20  7:22       ` Sebastien Vauban [this message]
2011-09-19 15:46 ` Martyn Jago
2011-09-19 16:04   ` Eric Schulte
2011-09-20  8:03     ` Martyn Jago
2011-09-20 15:01       ` Eric Schulte
2011-09-21  4:18         ` Martyn Jago
2011-09-21 12:20           ` Eric Schulte
2011-09-19 19:43   ` Sebastien Vauban

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:

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=80d3evy8yj.fsf@somewhere.org \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \


* 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


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