[gambit-list] Unit Testing
lucier at math.purdue.edu
Fri May 6 15:01:58 EDT 2022
On 5/2/22 4:57 PM, Thomas Hage wrote:
> I am learning Scheme on my own by exploring gambit by personal needs.
> Therefore there is a huge lack of experience on my side.
> Prior to my current project I felt in love with Test Driven Development.
> Scheme enabled me to improve my workflow by programming interactive -
> sufficiating my own requirements.
> The downside is that I am unable to include unit test into my current
> workflow. Any advice would be appreciated.
> In order to cover my current project in retrospective, I want to create
> tests (note that the usability of the provided test suite requires heavy
> exploration >:-) ).
> In both cases - testing afterwards or prior to implementing
> functionality - I am relying on branch coverage heavily.
> Since I am covering R5RS only, I am wondering if there is a test suite
> which can provide me with branch coverage (regardless of output
> I am aware about the following two facts:
> - In order to programming test-driven, a IDE suggestion implementations
> is required (not required)
> - the functional programming paradigm should enable me to cover my code
> by determine the permutations of arguments. I want to support this with
> branch coverage, so that I suspend my current workflow and resume
I don't know precisely what you're looking for, but here is a bit of
what I know about test coverage (not "branch coverage").
One can configure Gambit with "--enable-coverage", which, if compiling
with the GCC C compiler, enables both "-ftest-coverage" and
Unfortunately, recent versions of GCC incorporate an optimization pass
at the "-O1" optimization level that cannot handle code with large
switch statements or computed goto's, that should be disabled when using
test coverage, see
So one could use
./configure CC='gcc -fno-tree-loop-im' --enable-test-coverage
This will report which lines in the generated .c files are executed,
rather than which lines in the original .scm files are executed. This
is inconvenient unless you know how to read Gambit's machine-generated C
code; to track which lines in the .scm files are executed, configure with
./configure CC='gcc -fno-tree-loop-im' --enable-test-coverage --track-scheme
Scheme code that uses macros to simplify generating several copies of
repetitive code (e.g., the way Gambit's runtime has a large macro to
generate code for operations on vectors, then u8vectors, then strings,
then ...) will not give you good information on test coverage with
--track-scheme. If you want to know which parts of highly macrofied
code are truly executed, then you'll need to avoid --track-scheme and
just examine the coverage statistics for the .c files---which means
you'll need to keep the .c files, with the -keep-temp option to the
Gambit compiler, e.g.,
> gsc -exe -keep-temp test.scm
will keep the test.c around, which will be needed when running gcov on
the generated coverage statistics files.
This is all from a Linux/MacOS perspective, so I don't know whether it
will help you.
More information about the Gambit-list