emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Testing
@ 2010-03-01  8:54 Martin Pohlack
  2010-03-20  0:18 ` A testing framework (was: Testing) Martin Pohlack
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Pohlack @ 2010-03-01  8:54 UTC (permalink / raw)
  To: org-mode

Hi All,

I have been using org-mode for a while now and am quite happy with the
features it provides.  Occasionally, I update to the current git head
to get some fancy new features ;-).

I am, however, more and more reluctant to do so out of fear of loosing
parts of my data due to newly introduced bugs.

Just to be clear, I'm not writing here to blame anyone for bugs.  I
understand that they are probably inevitable on the path to new
features.

In the last time I often found long-corrupted entries in rarely
expanded subtrees of my org files.  That kind of scares me as it
greatly reduces the trust I can have in “my system”.

For example, I started using mrd-org-smartwrap.el for wrapping long
lines.  As it turned out (much later) some irregularities in this mode
distort the parsing of headline / entry boundaries.  Consequently, I
corrupted some entries in my trees without noticing it for a long time.
One particularly nasty effect was that recurring items where finally
marked as DONE with mrd-org-smartwrap active, instead of jumping to
the next recurrence.

What I want to propose here is to have a collection of test cases
which could be used to verify org-mode's integrity with regard to
certain features.  This email is meant to start a discussion on this
topic.

I currently envision each test-case to have five parts:

1. An input file: This file is the basis for a test and contains the
   initial state of an org-mode file.
2. A sequence of actions to operate on the input file.
3. An expected output file: This file resembles the transformed input
   file after the action sequence.  The actual output file can be
   compared to this expected file.
4. An expected visual representation of the org-mode buffer in emacs
   after the action sequence (like a screenshot but character based).
   This is required to capture visibility related bugs.  Those would
   not be visible from the actual output file alone.
5. An environment with an init.el / .emacs to customize org-mode for a
   certain test run.

So 1., 2., and 5. are the input of the test process.  The test succeeds
if the captured visual representation equals 4 and if the captured
output file equals 3.


Let me give you an example:

1.
---------->8---------->8---------->8---------->8---------->8----------
* TODO test
  SCHEDULED: <2010-03-01 Mo +1w>
---------->8---------->8---------->8---------->8---------->8----------

2.
---------->8---------->8---------->8---------->8---------->8----------
(beginning-of-buffer)
(org-todo 'done)
(save-buffer)
---------->8---------->8---------->8---------->8---------->8----------

3.
---------->8---------->8---------->8---------->8---------->8----------
* TODO test
  SCHEDULED: <2010-03-08 Mo +1w>
  - State "WAIT"       from "TODO"       [2010-03-01 Mo 09:45]
  :PROPERTIES:
  :LAST_REPEAT: [2010-03-01 Mo 09:45]
  :END:
---------->8---------->8---------->8---------->8---------->8----------

4.
---------->8---------->8---------->8---------->8---------->8----------
* TODO test
  SCHEDULED: <2010-03-08 Mo +1w>
  - State "WAIT"       from "TODO"       [2010-03-01 Mo 09:45]
  :PROPERTIES:…
---------->8---------->8---------->8---------->8---------->8----------

5.
(My current setup emitted for brevity.)


1. and 3. may have to be extended to a set of files if more complex
features should be tested like querying several files or export to PDF
/ ….

3. and 4. may need some wild-card representation for the timestamps in
order to make the equality comparison portable.

I imagine that bug reports could be accompanied by such test cases.
An example, the expected output, and a sequence of actions should
belong there anyways :-).

What do you guys think?

Cheers,
Martin Pohlack

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

* A testing framework (was: Testing)
  2010-03-01  8:54 Testing Martin Pohlack
@ 2010-03-20  0:18 ` Martin Pohlack
  2010-03-21  7:26   ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Pohlack @ 2010-03-20  0:18 UTC (permalink / raw)
  To: org-mode

Hi Again,

I assume all of you ignored my previous email due to me choosing a
clever subject :-/.

I went ahead anyway and implemented a first version of the framework.

It currently contains 2 sample test cases, one that works and one that
fails with my org-mode version.

> 3. and 4. may need some wild-card representation for the timestamps in
> order to make the equality comparison portable.

This problem is currently solved by filtering the output and comparing
generalized output.

Please have a look at the framework here:

  http://github.com/martinp26/org-mode-test

Cheers,
Martin Pohlack

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

* Re: A testing framework (was: Testing)
  2010-03-20  0:18 ` A testing framework (was: Testing) Martin Pohlack
@ 2010-03-21  7:26   ` Carsten Dominik
  2010-03-21 19:48     ` A testing framework Martin Pohlack
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-03-21  7:26 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: org-mode

Hi Martin,

thanks for this.

we had an earlier threads about testing frameworks:

http://orgmode.org/worg/org-tests/index.php

http://thread.gmane.org/gmane.emacs.orgmode/8759/focus=8775

http://thread.gmane.org/gmane.emacs.orgmode/8743/focus=8743

I think it would be great to have a testing framework and a
lot of tests, but I do not have time to make this happen.
Maybe you can try to get the people who were active in those
threads and energize them?

- Carsten


On Mar 20, 2010, at 1:18 AM, Martin Pohlack wrote:

> Hi Again,
>
> I assume all of you ignored my previous email due to me choosing a
> clever subject :-/.
>
> I went ahead anyway and implemented a first version of the framework.
>
> It currently contains 2 sample test cases, one that works and one that
> fails with my org-mode version.
>
>> 3. and 4. may need some wild-card representation for the timestamps  
>> in
>> order to make the equality comparison portable.
>
> This problem is currently solved by filtering the output and comparing
> generalized output.
>
> Please have a look at the framework here:
>
>  http://github.com/martinp26/org-mode-test
>
> Cheers,
> Martin Pohlack
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: A testing framework
  2010-03-21  7:26   ` Carsten Dominik
@ 2010-03-21 19:48     ` Martin Pohlack
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Pohlack @ 2010-03-21 19:48 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode

Hi Carsten, all,

On 21.03.2010 08:26, Carsten Dominik wrote:
> we had an earlier threads about testing frameworks:
> 
> http://orgmode.org/worg/org-tests/index.php
> 
> http://thread.gmane.org/gmane.emacs.orgmode/8759/focus=8775
> 
> http://thread.gmane.org/gmane.emacs.orgmode/8743/focus=8743

Very interesting, I just went through all this.

From above material, two general approaches have been considered for
testing org-mode:
* Lisp based unit testing.
* Example-file based feature testing.

I am targeting the second approach here for now as I think it may
provide more benefit per time spent and would allow more people to
participate easily.

I hope that every emacs user will be able to write tests with my
framework.  Basically only an example test case and the expected
result should be need for tests, together with a minimal description
of the setup.

If only an example file triggering a bug is available, a corresponding
test can be crafted with minimal effort.


For now I have a minimal framework running with two tests
demonstrating expected behavior for folding and a bug in the version
I'm using.

I would like to enquire comments regarding the following open issues,
where I have no satisfying solution yet:

* I would like to start the test in something like a temporally stable
  setup, such that generated timestamps would be somewhat predictable
  (basically with the system clock set to 1.1.2005 20:00, or something
  like that).

  There are several levels where this could be achieved, ranging from:
  1. Experimental patches to the Linux kernel,
  2. Library wrappers using LD_PRELOAD around emacs to virtualize the
     time and gettimeofday system calls,
  3. Advised lisp functions for obtaining time stamps, and
  4. Post processing the test output to generalized time stamps.

  Currently, I'm going with 4, 3 may make sense if someone could
  identify the hopefully 2-3 functions to be advised.

  2 and 1 are probably too Linux specific and I'm not sure if 2 works
  with emacs.

  Comments?

* Currently I use a list of lisp functions for specifying the behavior
  to be executed in a test, for example:

  (org-todo)

  or

  (org-end-of-line)
  (org-cycle)

  This is not very intuitive for users.  I would rather like something
  like a recorded macro to execute.

  For example:

  "end, tab"

  Does anyone here has a tip how to specify a list of user-input
  actions in a file and play that back?

* For visual comparison I currently simply save the visible part of
  buffers.

  One may get a step further here and also capture properties, faces and
  the cursor position.  I remember vaguely that there is such a
  facility somewhat related to rich text in emacs, but wasn't able to
  find it again.  Do you guys know of such a thing?

> I think it would be great to have a testing framework and a
> lot of tests, but I do not have time to make this happen.
> Maybe you can try to get the people who were active in those
> threads and energize them?

I assumed everyone still interested in contributing to org-mode is
still lurking in this list.  So speak up if you are interested in
contributing to the tests :-).

Cheers,
Martin

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

end of thread, other threads:[~2010-03-21 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-01  8:54 Testing Martin Pohlack
2010-03-20  0:18 ` A testing framework (was: Testing) Martin Pohlack
2010-03-21  7:26   ` Carsten Dominik
2010-03-21 19:48     ` A testing framework Martin Pohlack

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).