The Spin Regression Tests


Regression tests are a collection of extensions executed to test various parts of the system and a control command that drives those extensions. These tests should be run after each major modification to the system or the compiler to ensure that things known (or thought) to work still do. Each component of the system should be accompanied by a set of regression tests that would somehow verify its functionality. Additionally, if a bug is fixed, providing a simple test that brakes verifies the fix.

Each regression test is installed into the system as a shell command and can be executed independently of other tests or all regression tests can be executed together. Functionally, a regression test is a collection of procedures (test cases) that return a BOOLEAN value indicating whether the case test succeeded or not. The regression control is also a shell command and it allows changing the mode of execution of regression tests. It is a statically linked extension, hence it is always available.

Shell commands

Before you run the tests: If you want to execute all or some of the tests: The amount of information printed by regression tests can be regulated

Interpreting results

A regression test failed if a line >>> `test-name' => ERROR is printed. There will be also a line that says which case have failed. Run the test in a verbose mode to see how exactly the test failed.

Existing tests

Writing a regression test

To write a regression test you need:

and of course an implementation of all those procedures which tests something important. A regression test with a name "test" is expected to be installed as a command "regress test", and is supposed to execute all of the procedure cases clearly indicating which one was passed and which one not. To ease writing tests and to provide uniformity, a generic RegressionTest is provided. All you need to do is to give it those four things in a right interface. A template regress.tmpl takes care of putting everything together so that in your m3makefile just type "RegressionModule(YourTestModuleName)" and you got yourself a regression test. Here's an example of the simple test:

Hello.i3
The interface
Hello.m3
The implementation
m3makefile
The m3makefile.
hello.conf
The downloadable config file.

How does it work?

The RegressionTest generic takes the name of the test and the help string and installs the test as a right command. It provides right guards and the Run procedure which iterates over all test cases and printing messages. The start-up (Start) procedure is executed before any test case and it enables initialization of the test. The clean-up (End) procedure is executed after all test cases and can be used, for example, to deallocate memory, uninstall handlers, etc. All test cases and the cleanup procedure are executed even if one of the cases fails or raises an exception.

Text-based regression tests

There is an alternative implementation of regression tests. The primary one (described above) forces the writer of a test to check internally whether a test has failed or not. To ease the task of programming regression test, text-based regressions are avaialble. Those tests still can test internally for inconsistency in results and return a result that indicates success or failure. They can however delegate this responsibility to the right generic by providing it with a text that is the expected output from the test. The generic matches the acutual output with the expected one and if they are different, it reports a failure. All other options are identical with regular regression tests.

Some important files

Five files are involved in implementing regression tests:
RegressionTest.mg.
Generic implementation of regular regressions.
RegressionTest.ig.
Generic interface of regular regressions.
TextRegressionTest.mg.
Generic implementation of text-based regressions.
TextRegressionTest.ig.
Generic interface of text-based regressions.
Regress.m3.
Regression control implementation.
Regress.i3.
Regression control interface.
regress.tmpl.
The quake directives that instantiate your generic from the RegressionModule directive.

Conventions

Please, follow these several rules. They will make creating, maintaining, and running regression tests easier.

Suggested usage

The tests can may our life easier if we use them right. We will learn what is "right" as we use them but for now a couple suggestions from the author of this page. None of these rules contain words like "always" or "never". Everyone has to judge for yourself, but it's good to remember that sometimes people other than the programmer who wrote a piece of code have to believe that it works.

Submitting new tests

What should be tested and how is sometimes hard to decide, but two major guidelines are proposed: Also, it is better to submit too many tests then too few. If the number of tests ever becomes a problem we can always prioritize them, if a test is missing someone may spend hours trying to figure out why stuff doesn't work.

Testing

"Run them all, run them often"

Running tests

ToDo

I am still working on the regression test control to provide more flexible execution of tests and easier interpretation of results.


Przemek Pardyak, May 20th, 1996