5

In most programming languages one has the equivalent of a functional test, that can test code and see if the required output is correct and find edge cases.

Is there a way to write similar tests, to see if a piece of LaTeX code satisfies a collection of tests?

A hypothetical example could be to automate testing of submitted LaTeX code for people doing an introductory course. A small case could be that students are required to include a set of packages, but this could for instance be done, one by one, or in bulk or out of order. So only robust way that makes sense to me is to have the equivalent of having the code included and actually run in a LaTeX environment, in order to have certain test cases pass, or fail, that could supply appropriate feedback.

Are such packages or a suggested approach available?

7

The LaTeX sources 2e and (separately) expl3 code have quite an extensive test suite. Basically you cause anything you want to be tested to be traced to the log file. Package loading etc is already traced or you can add tracing commands as needed. Then the log files are "normalised" with some text edits in perl to remove absolute paths and dates etc, and then these can be compared against results on later runs.

The test files and expected results are here

http://latex-project.org/svnroot/latex2e-public/testfiles/

  • 1
    Perhaps worth adding that to test the typeset output, setting \showboxdepth and \showboxbreadth to \@maxdimen, then using \showbox on a boxed-up version of the output is a usable approach (done for example in the expl3 box module tests). – Joseph Wright Sep 28 '13 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.