Wednesday, January 19, 2011

How to run TAP::Harness tests written in Guile?

The usual approach of

test:
    $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INCDIRS)')" $(TEST_FILES)

fails to run Guile scripts, because it passes to Guile the extra parameter "-w".

  • One possible approach is to set up your project as follows.

    Your directory structure is as follows:

    ./project              Your project files
    ./project/t/*.t        Your unit test scripts
    ./project/t/scripts/*  Auxiliary scripts used by your unit tests

    Your ./project/Makefile contains the following:

    PERL = /usr/bin/perl
    TEST_LIBDIRS = ./lib
    RUN_GUILE_TESTS = ./t/scripts/RunGuileTests.pl
    TEST_FILES = ./t/*.t
    
    test:
        $(PERL) -I$(TEST_LIBDIRS) $(RUN_GUILE_TESTS) $(TEST_FILES)

    Your ./project/t/scripts/RunGuileTests.pl contents are:

    #!/usr/bin/perl -w
    # Run Guile tests - filenames are given as arguments to the script.
    
    use TAP::Harness;
    my @tests = @ARGV;
    my %args = (
        verbosity => 0,
        timer => 1,
        show_count => 1,
        exec => ['/usr/bin/guile', '-s'],
        );
    my $harness = TAP::Harness->new( \%args );
            $harness->runtests(@tests);
    
    # End of RunGuileTests.pl

    Your Guile test scripts should start with:

    #!/usr/bin/guile -s
    !#
    ; Description of your tests
    From Omer Zak

0 comments:

Post a Comment