Text -syb +hunit
Text-based test controller for running HUnit tests and reporting results as text, usually to a terminal.
As the general text-based test controller (runTestText) executes a test, it reports each test case start, error, and failure by constructing a string and passing it to the function embodied in a PutText. A report string is known as a "line", although it includes no line terminator; the function in a PutText is responsible for terminating lines appropriately. Besides the line, the function receives a flag indicating the intended "persistence" of the line: True indicates that the line should be part of the final overall report; False indicates that the line merely indicates progress of the test execution. Each progress line shows the current values of the cumulative test execution counts; a final, persistent line shows the final count values.
The PutText function is also passed, and returns, an arbitrary state value (called st here). The initial state value is given in the PutText; the final value is returned by runTestText.
Two reporting schemes are defined here. putTextToHandle writes report lines to a given handle. putTextToShowS accumulates persistent lines for return as a whole by runTestText.
putTextToHandle writes persistent lines to the given handle, following each by a newline character. In addition, if the given flag is True, it writes progress lines to the handle as well. A progress line is written with no line termination, so that it can be overwritten by the next report line. As overwriting involves writing carriage return and blank characters, its proper effect is usually only obtained on terminal devices.
Accumulates persistent lines (dropping progess lines) for return by runTestText. The accumulated lines are represented by a ShowS (String -> String) function whose first argument is the string to be appended to the accumulated report lines.
Executes a test, processing each report line according to the given reporting scheme. The reporting scheme's state is threaded through calls to the reporting scheme's function and finally returned, along with final count values.