>>>>> Zack Williams <[email protected]> writes:

> Could the example code in the docs be testable against ledger?  This would
> be a bit of trouble to get going, but could pay dividends in the long run -
> if a test were to fail it would either be a bug in ledger, or a
> functionality change that would require a change in the docs.

There is already some code in place to do this, it's found in
lisp/ldg-texi.el.  However, I'd like to change this scheme to using an
automated Python script as part of the build process, so that no discrepancies
between test/manual and ledger.texi can ever occur.

So, here's how it works:

When presenting data to the user, use this form:

    @c data some-identifier
    @smallexample
    Ledger input for the user to see, before we run our commands.
    @end smallexample

    Now talk about the command you will run.

    @c test example-name: reg -f $some-identifier foo bar baz
    @smallexample
    This is the output you expect to see from the command.  Note
    that the following args are always added to every command:
      --args-only --columns=80 --no-color
    @end smallexample

You can have multiple output blocks refer to the same input block using -f
$data-block-identifier in each.

These embedded tests get processed out into the following file format:

    Ledger input for the user to see, before we run our commands.

    test reg foo bar baz
    This is the output you expect to see from the command.  Note
    that the following args are always added to every command:
      --args-only --columns=80 --no-color
    end test

The last thing about this I want to support is "hidden" sections, both before
and after the input text and the result text, so that you can provide
additional information that is relevant to the test, but not relevant to what
you want the user to see.  I think it should look like this:

    @c data some-identifier
    @smallexample
    These are source lines that get output to the test, but are deleted from
    the generated Texinfo file.
    __DATA__
    Ledger input for the user to see, before we run our commands.
    __END__
    And these will come after the test.  Great place for some assertions.
    @end smallexample

    Now talk about the command you will run.

    @c test example-name: reg -f $some-identifier foo bar baz
    @smallexample
    Again, for line of output you expect to see and want tested, but which
    aren't relevant.
    __DATA__
    This is the output you expect to see from the command.  Note
    that the following args are always added to every command:
      --args-only --columns=80 --no-color
    __END__
    And the same here, for irrelevant output after your example.
    __ERROR__
    Anything here is expected error output, just so the test passes if your
    example is intentionally wrong.  This is not displayed to the user either.
    @end smallexample

John

Reply via email to