diff --git a/Configure.pl b/Configure.pl index f598cda..195ae37 100644 --- a/Configure.pl +++ b/Configure.pl @@ -196,6 +196,11 @@ run the tests described in C<--test=build>. Store the results of each configuration step in a Storable F<.sto> file on disk, for later analysis by F methods. +=item C<--coveragedir> + +In preparation for calling C to perform coverage analysis, +provide a user-specified directory for top level of HTML output. + =item Operating system-specific configuration options =over 4 diff --git a/config/auto/coverage.pm b/config/auto/coverage.pm new file mode 100644 index 0000000..590dd03 --- /dev/null +++ b/config/auto/coverage.pm @@ -0,0 +1,76 @@ +# Copyright (C) 2001-2008, Parrot Foundation. + +=head1 NAME + +config/auto/coverage- Check whether coverage analysis tools are present + +=head1 DESCRIPTION + +Coverage analysis is the measurement of the extent to which a program's source +code is exercised by its tests. + +In Parrot, we can perform coverage analysis +on our Parrot source code (well, at least on F<.c> and F<.pmc> files) and on +the Perl 5 components used in our tools. + +To conduct such analysis, we need +the C coverage utility F and two utilities, F and F, +which are included in the Devel-Cover distribution from CPAN. (Paul +Johnson++). This configuration step determines whether those utilities are +present. + +=cut + +package auto::coverage; + +use strict; +use warnings; + +use File::Which; +use base qw(Parrot::Configure::Step); +use Parrot::Configure::Utils ':auto'; + + +sub _init { + my $self = shift; + my %data; + $data{description} = q{Are coverage analysis tools installed}; + $data{result} = q{}; + return \%data; +} + +sub runstep { + my ( $self, $conf ) = @_; + + my %utils_needed = map { $_ => undef } qw( gcov gcov2perl cover ); + foreach my $util (keys %utils_needed) { + $utils_needed{$util} = which($util); + } + my @utils_lacking = grep { ! defined $utils_needed{$_} } keys %utils_needed; + if (@utils_lacking) { + $self->set_result("lacking @utils_lacking"); + } + else { + $conf->data->set( + "has_coverage_tools" => 1, + %utils_needed, + ); + $self->set_result('yes'); + } + return 1; +} + +1; + +=head1 REFERENCES + +L. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: diff --git a/config/auto/perldoc.pm b/config/auto/perldoc.pm index 41b7f34..8ff8465 100644 --- a/config/auto/perldoc.pm +++ b/config/auto/perldoc.pm @@ -52,9 +52,9 @@ sub runstep { E_NOTE - opendir OPS, 'src/ops' or die "opendir ops: $!"; - my @ops = sort grep { !/^\./ && /\.ops$/ } readdir OPS; - closedir OPS; + opendir my $OPS, 'src/ops' or die "opendir ops: $!"; + my @ops = sort grep { !/^\./ && /\.ops$/ } readdir $OPS; + closedir $OPS; my $TEMP_pod = join q{ } => map { my $t = $_; $t =~ s/\.ops$/.pod/; "ops/$t" } @ops; diff --git a/config/gen/makefiles/root.in b/config/gen/makefiles/root.in index 53f691e..c7f776a 100644 --- a/config/gen/makefiles/root.in +++ b/config/gen/makefiles/root.in @@ -35,6 +35,7 @@ DATA_DIR = "@datadir@" DOC_DIR = "@docdir@" VERSION_DIR = "@versiondir@" SRC_DIR = "@srcdir@" +COVERAGE_DIR = "@coveragedir@" ############################################################################### # @@ -1823,43 +1824,58 @@ editor-clean : # The --running-make-test argument is currently used by long-running tests # to disable GC_DEBUG. EXTRA_TEST_ARGS = --gc-debug -DISTRO_TEST_FILES = \ - t/distro/*.t + +# Directories holding tests +DYNOPLIBS_TESTS_DIR = t/dynoplibs +DYNPMC_TESTS_DIR = t/dynpmc +INSTALL_TOOLS_TESTS_DIR = $(TOOLS_TESTS_DIR)/install +OO_TESTS_DIR = t/oo +OP_TESTS_DIR = t/op +PIR_TESTS_DIR = t/pir +PMC_TESTS_DIR = t/pmc +HARNESS_TESTS_DIR = t/pharness +MANIFEST_TESTS_DIR = t/manifest +PMC2CUTILS_TESTS_DIR = $(TOOLS_TESTS_DIR)/pmc2cutils +TOOLS_TESTS_DIR = t/tools + BENCHMARK_TEST_FILES = \ t/benchmark/*.t -PERL_TEST_FILES = \ - t/perl/*.t +BUILDTOOLS_TEST_FILES = \ + $(PMC2CUTILS_TESTS_DIR)/*.t \ + $(HARNESS_TESTS_DIR)/*.t CODINGSTD_TEST_FILES = \ t/codingstd/*.t -RUN_TEST_FILES = \ - t/run/*.t -RUNCORE_TEST_FILES = \ - --runcore-tests -SRC_TEST_FILES = \ - t/src/*.t -TOOLS_TEST_DIR = t/tools -TOOLS_TEST_FILES = $(TOOLS_TEST_DIR)/tools/*.t -LIBRARY_TEST_FILES = @library_tests@ -PMC2CUTILS_DIR = $(TOOLS_TEST_DIR)/pmc2cutils -HARNESS_DIR = t/pharness -BUILDTOOLS_TEST_FILES = \ - $(PMC2CUTILS_DIR)/*.t \ - $(HARNESS_DIR)/*.t -MANIFEST_DIR = t/manifest -INSTALL_TOOLS_DIR = $(TOOLS_TEST_DIR)/install -MANIFEST_TEST_FILES = \ - $(MANIFEST_DIR)/*.t \ - $(INSTALL_TOOLS_DIR)/*.t -EXAMPLES_TEST_FILES = \ - t/examples/*.t CONFIGURE_TEST_FILES = \ t/configure/*.t \ t/steps/*.t +DISTRO_TEST_FILES = \ + t/distro/*.t +DYNOPLIBS_TEST_FILES = $(DYNOPLIBS_TESTS_DIR)/*.t +DYNPMC_TEST_FILES = $(DYNPMC_TESTS_DIR)/*.t +EXAMPLES_TEST_FILES = \ + t/examples/*.t +HEADERIZER_TEST_FILES = $(TOOLS_TESTS_DIR)/dev/headerizer/*.t +LIBRARY_TEST_FILES = @library_tests@ +MANIFEST_TEST_FILES = \ + $(MANIFEST_TESTS_DIR)/*.t \ + $(INSTALL_TOOLS_TESTS_DIR)/*.t +OO_TEST_FILES = $(OO_TESTS_DIR)/*.t +OP_TEST_FILES = $(OP_TESTS_DIR)/*.t PBC_TEST_FILES = \ t/op/testlib/test_strings.pbc \ t/pmc/testlib/annotations.pbc \ t/pmc/testlib/number.pbc -HEADERIZER_TEST_FILES = $(TOOLS_TEST_DIR)/dev/headerizer/*.t +PERL_TEST_FILES = \ + t/perl/*.t +PIR_TEST_FILES = $(PIR_TESTS_DIR)/*.t +PMC_TEST_FILES = $(PMC_TESTS_DIR)/*.t +RUN_TEST_FILES = \ + t/run/*.t +RUNCORE_TEST_FILES = \ + --runcore-tests +SRC_TEST_FILES = \ + t/src/*.t +TOOLS_TEST_FILES = $(TOOLS_TESTS_DIR)/tools/*.t # pbc files used for several tests; # not needed for build, hence this target is not included in 'all' @@ -1890,6 +1906,9 @@ test : test_core test_core: test_prep $(PERL) t/harness $(EXTRA_TEST_ARGS) +test_runcore: test_prep + $(PERL) t/harness $(EXTRA_TEST_ARGS) $(RUNCORE_TEST_FILES) + # run the test suite, create a TAP archive and send it off to smolder smolder_test : test_prep $(PERL) t/harness $(EXTRA_TEST_ARGS) --archive --send-to-smolder @@ -1965,6 +1984,24 @@ testexec: test_prep src_tests : $(PERL) t/harness $(SRC_TEST_FILES) +dynoplibs_tests : + $(PERL) t/harness $(DYNOPLIBS_TEST_FILES) + +dynpmc_tests : + $(PERL) t/harness $(DYNPMC_TEST_FILES) + +oo_tests : + $(PERL) t/harness $(OO_TEST_FILES) + +op_tests : + $(PERL) t/harness $(OP_TEST_FILES) + +pir_tests : + $(PERL) t/harness $(PIR_TEST_FILES) + +pmc_tests : + $(PERL) t/harness $(PMC_TEST_FILES) + # Command line and various environments run_tests : $(PERL) t/harness $(RUN_TEST_FILES) @@ -2455,6 +2492,7 @@ splint : all | grep -v 'Source code error generation point' COVER_FLAGS = -fprofile-arcs -ftest-coverage + COVER_DIRS = \ src \ src/call \ @@ -2462,15 +2500,20 @@ COVER_DIRS = \ src/dynpmc \ src/gc \ src/interp \ + src/io \ + src/nci \ src/ops \ src/packfile \ src/pmc \ src/runcore \ src/string \ src/string/encoding \ + frontend/parrot \ + frontend/parrot_debugger \ + frontend/pbc_dump \ + frontend/pbc_merge \ $(BUILD_DIR) \ $(BUILD_DIR)/t/perl \ - src/io \ compilers/imcc cover: \ @@ -2497,10 +2540,52 @@ cover: \ done cover -ignore_re '^\/usr\/local\/bin' +QUICKCOVER_DIRS = \ + src \ + src/call \ + src/dynoplibs \ + src/dynpmc \ + src/gc \ + src/interp \ + src/io \ + src/nci \ + src/ops \ + src/packfile \ + src/pmc \ + src/runcore \ + src/string \ + src/string/encoding \ + frontend/parrot \ + frontend/parrot_debugger \ + frontend/pbc_dump \ + frontend/pbc_merge \ + compilers/imcc + +COVER = @cover@ +GCOV = @gcov@ +GCOV2PERL = @gcov2perl@ + +quickcover: \ + cover.dummy \ + cover-test_runcore + build_dir=$$PWD; \ + $(COVER) -delete; \ + for dir in $(QUICKCOVER_DIRS); \ + do \ + cd $$dir; \ + $(GCOV) *.c; \ + cd $$build_dir; \ + $(GCOV2PERL) -db $(COVERAGE_DIR) $$dir/*.gcov; \ + done + $(COVER) $(COVERAGE_DIR) -ignore_re '^\/usr\/local\/bin' + cover.dummy: $(PERL) Configure.pl --ccflags="$(CC_FLAGS) $(COVER_FLAGS)" \ --linkflags="$(COVER_FLAGS)" --ldflags="$(COVER_FLAGS)" +cover-test_runcore: cover.dummy + -@make@ test_runcore + cover-testb: cover.dummy -@make@ testb @@ -2519,6 +2604,24 @@ cover-testr: cover.dummy cover-src: cover.dummy -@make@ src_tests +cover-dynoplibs: cover.dummy + -@make@ dynoplibs_tests + +cover-dynpmc: cover.dummy + -@make@ dynpmc_tests + +cover-oo: cover.dummy + -@make@ oo_tests + +cover-op: cover.dummy + -@make@ op_tests + +cover-pir: cover.dummy + -@make@ pir_tests + +cover-pmc: cover.dummy + -@make@ pmc_tests + cover-run: cover.dummy -@make@ run_tests @@ -2544,7 +2647,7 @@ cover-distro: cover.dummy -@make@ distro_tests cover-clean: - $(PERL) -MCwd -e 'for my $$dir ( qw ( $(COVER_DIRS) ) ) {my $$cwd = cwd(); chdir $$dir; print "Deleting gcov-generated files in $$dir\n"; unlink glob( "*.gcda *.gcno *.gcov" ); chdir $$cwd;}' + $(PERL) -MCwd -e 'for my $$dir ( qw ( $(COVER_DIRS) $(QUICKCOVER_DIRS) t/src ) ) {my $$cwd = cwd(); chdir $$dir; print "Deleting gcov-generated files in $$dir\n"; unlink glob( "*.gcda *.gcno *.gcov" ); chdir $$cwd;}' ############################################################################### # diff --git a/config/init/defaults.pm b/config/init/defaults.pm index 2d295ac..00efe0b 100644 --- a/config/init/defaults.pm +++ b/config/init/defaults.pm @@ -248,6 +248,7 @@ sub runstep { tempdir => File::Spec->tmpdir, PKGCONFIG_DIR => $conf->options->get('pkgconfigdir') || '', + coveragedir => $conf->options->get('coveragedir') || $build_dir, ); # TT #855: Profiling options are too specific to GCC diff --git a/lib/Parrot/Configure/Options/Conf/Shared.pm b/lib/Parrot/Configure/Options/Conf/Shared.pm index 2de3a0b..05ed095 100644 --- a/lib/Parrot/Configure/Options/Conf/Shared.pm +++ b/lib/Parrot/Configure/Options/Conf/Shared.pm @@ -17,6 +17,7 @@ our @shared_valid_options = qw{ ccflags ccwarn configure_trace + coveragedir cxx darwin_no_fink darwin_no_macports diff --git a/lib/Parrot/Configure/Step/List.pm b/lib/Parrot/Configure/Step/List.pm index 1bbc6d4..a0446dd 100644 --- a/lib/Parrot/Configure/Step/List.pm +++ b/lib/Parrot/Configure/Step/List.pm @@ -57,6 +57,7 @@ my @steps = qw( auto::gettext auto::snprintf auto::perldoc + auto::coverage auto::pod2man auto::ctags auto::revision diff --git a/t/steps/auto/coverage-01.t b/t/steps/auto/coverage-01.t new file mode 100644 index 0000000..7b7d1f0 --- /dev/null +++ b/t/steps/auto/coverage-01.t @@ -0,0 +1,72 @@ +#! perl +# Copyright (C) 2007, Parrot Foundation. +# auto/coverage-01.t + +use strict; +use warnings; +use Test::More tests => 7; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::auto::coverage'); +use Parrot::BuildUtil; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Step::Test; +use Parrot::Configure::Test qw( + test_step_constructor_and_description +); + +########## regular ########## + +my ($args, $step_list_ref) = process_options( { + argv => [], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure::Step::Test->new; +$conf->include_config_results( $args ); + +my $pkg = q{auto::coverage}; + +$conf->add_steps($pkg); + +my $serialized = $conf->pcfreeze(); + +$conf->options->set(%{$args}); +my $step = test_step_constructor_and_description($conf); +ok($step->runstep($conf), "runstep() completed successfully"); +ok(defined($step->result), "Result was defined"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +auto/coverage-01.t - test auto::coverage + +=head1 SYNOPSIS + + % prove t/steps/auto/coverage-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test auto::coverage. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::coverage, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: