vmg/clar — pull request #58 by ianohara (2014-06-20 19:43:13+00:00)
Title: Allow test file paths with hyphens by replacing hyphens with underscores in module name

We like to have a ``tests`` dir that exactly mirrors the structure of our projects' ``src`` directory. In the following example, ``generate.py`` scans the ``tests`` directory for tests:

/
src/
data-structures/
circular-buffer.c
tests/
data-structures/
circular-buffer.c

Because the filenames are used for the test names, leaving the the hyphen necessitates illegal test function names. For example, the circular buffer initialize function would need to look like:

void test_data-structures_circular-buffer__initialize(void);

which is not valid C. Substituting underscores for hyphens in module names fixes this.

This should not break any existing systems because before this, tests could not exist in files whose path viewed by ``generate.py`` contained a hyphen.

If this approach is too rigid for you, I can add an optional substitutes argument (or something similar) to the TestSuite constructor which species ``tr`` style substitutions that should take place in the module names. That's a bit more involved than this one liner, though.