Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: C test suite management with perl

by jeffa (Bishop)
on Sep 09, 2015 at 17:39 UTC ( #1141450=note: print w/replies, xml ) Need Help??

in reply to C test suite management with perl

Why not just use prove? If you just want to run your tests, and you don' t care about the order they are run in (and you should not to take advantage of forked parallelization) then prove will handle pretty much everything your script does.

I put all my tests into a directory named t/ inside the project directory and run

prove -rlj6
from the project directory or
prove -rlj6 --formatter=TAP::Formatter::JUnit --timer t/| tee junit.xm +l
if i want to feed the results to a CI server like Jenkins, so it can build pretty graphs for me.

If you want to build an executable then perhaps you can leverage instead of rolling your own wheel from complete scratch. I recommend Module::Starter to start any and all projects. Once you have a proper, then you can use the shell to replace

#!/bin/sh perl Makefile.PL make make test # do something with newly created files make veryclean
If you need more control, then i suggest starting with a foundation like App::Prove.

Hope this helps, there are many branches to hit when falling down this tree. :)


(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: C test suite management with perl
by QuillMeantTen (Friar) on Sep 09, 2015 at 17:58 UTC

    I thought about that but I could not find a way to do it with C test files, at first I tried using Inline to be able to use prove easily but as more and more difficulties befell me I gave up in favor of the c library I linked
    I would love to know how to use module starter to make non perl projects though, would you be so kind as to expand on that?

      From the link you provided:

      C TAP Harness can run Perl test scripts directly and interpret the results correctly, and similarly the Perl Test::Harness module and prove command can run TAP tests written in other languages using, for example, the TAP library that comes with C TAP Harness. You can, if you wish, use the library that comes with C TAP Harness but use prove instead of runtests for running the test suite.


      (the triplet paradiddle with high-hat)

        it seems that to make a correct use of that library and the power of prove I am going to need more than the cursory knowledge I have of the autotools.
        I shall start reading some books I had put away for such a time right away

        Great and many thanks for your wise counsel and hints fellow monk you have set me on a path of better learning and understanding.

        Update: after fiddling around I found out that any makefile in the tests subdirectory is ignored, so I probably am missing something when writing my main After a bit of fiddling around I still have the error output, yet when I run make check-local I get undefined references error
        This is not surprising since the gcc command run does not include either the tap files or the main program's c files

        YAU(yet another update) I managed to make it work but I did not follow the c tap harness author instructions : I added a line to my so it builds the test executable before running the test suite, that way everything works fine. Still it feels a bit unelegant and like cheating, am I doing things right?

        So after some studying I think I'm starting to get autotools to do what I want (at least autoconf et automake) right now I'm confronted with a bit of a conundrum :

        For any test programs that need to be compiled, add build rules for them in, simliar to:
        tests_libtap_c_basic_LDADD = tests/tap/libtap.a

        this line is quite a mysterious : as I understand it, if I have in my tests directory a subfolder containing tests for a specific c file (lets call that test file specific_tests.c) to have the harness run those tests I'd need to add to the following line :


        Thing is if I add this line and then autoreconf I got the following output : warning: variable 'specific_tests_LDADD' is defined bu +t no program or library has 'specific_tests' as canonical name (possib +le typo)

        I must add that if I compile specific_tests myself into a specific_tests.t output file make checklocal runs perfectly "

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1141450]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-01-24 08:02 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (64 votes). Check out past polls.