imb / fctx

C unit testing in a header (works for C++ too!).
Other
36 stars 15 forks source link

Support the Test Anything Protocal #23

Closed imb closed 13 years ago

imb commented 13 years ago

Would like to move the standard log reporting to use the T.A.P. (http://testanything.org/wiki/index.php/Main_Page).

The existing "standard" would become "fctx", and "tap" would become the new default.

stsci-sienkiew commented 13 years ago

Adding a logger should be relatively simple.

I am also writing a logger. Mine is for pandokia format, which contains some information that is not present in TAP or Junit/XML.

My approach is this:

#include "fct.h"
#include "pandokia_fct.h"
FCT_BGN()
{
pandokia_fct_init();
FCT_QTEST_BGN(my_test) {
 ...

pandokia_fct_init(); replaces one of the entries in the FCT_LOGGER_TYPES array. This gives me the flexibility to add a new logger without changing FCTX at all. The cost is that I have to add two lines to my test program.

I suggest that this data item:

static fct_logger_types_t FCT_LOGGER_TYPES[] =

be changed to a linked list instead of a fixed size array, so that I can add my logger without destroying one of the existing loggers. Maybe there could also be "fct_define_logger()" to register a new logger, but maybe that is more than we really need.

imb commented 13 years ago

Take a look at the examples section in the repository on setting up a custom logger.

https://github.com/imb/fctx/tree/master/examples/custom_logger

There is support to add your own array of custom logs via the fctlog_install(). You can then re-write the FCT_BGN as,

#define CL_FCT_BGN()                 \
   FCT_BGN() {                       \
      fctlog_install(custlogs);

Where the custlogs is basically the same array as the FCT_LOGGER_TYPES.

This lets you install your logger alongside existing ones.