Author: particle
Date: Tue Jan 17 11:26:47 2006
New Revision: 11227
Added:
trunk/t/distro/test_file_coverage.t (contents, props changed)
Modified:
trunk/MANIFEST
Log:
tests: test file coverage
~ tests that all PMC classes have test files
~ two failing TODO tests
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Tue Jan 17 11:26:47 2006
@@ -1882,6 +1882,7 @@ t/configure/configure.t
t/configure/data.t []
t/configure/step.t []
t/distro/manifest_skip.t []
+t/distro/test_file_coverage.t []
t/doc/Parrot_Docs.t []
t/doc/opcode-doc.t []
t/doc/pod.t []
Added: trunk/t/distro/test_file_coverage.t
==============================================================================
--- (empty file)
+++ trunk/t/distro/test_file_coverage.t Tue Jan 17 11:26:47 2006
@@ -0,0 +1,109 @@
+#! perl
+# Copyright: 2001-2005 The Perl Foundation. All Rights Reserved.
+# $Id: manifest_skip.t 10933 2006-01-06 01:43:24Z particle $
+
+use strict;
+use warnings;
+use lib qw( . lib ../lib ../../lib );
+use Test::More;
+use File::Find qw( find );
+use File::Basename qw( fileparse );
+use File::Spec::Functions qw( catdir catfile );
+use Parrot::Config;
+
+
+=head1 NAME
+
+t/distro/test_file_coverage.t - make sure source files have matching tests
+
+=head1 SYNOPSIS
+
+ % prove t/distro/test_file_coverage.t
+
+=head1 DESCRIPTION
+
+Makes sure that specific source files have matching test files.
+
+=cut
+
+## make sure PMC files match test files
+PMC: {
+
+ my $pmc_dir = 'src/classes';
+ my $pmc_suffix = '.pmc';
+
+ my $test_dir = 't/pmc';
+ my $test_suffix = '.t';
+
+ my( @pmc_files, @test_files );
+
+
+ # find pmc files
+ find { no_chdir => 1,
+ wanted => sub{ files_of_type( [EMAIL PROTECTED],
$pmc_suffix ) },
+ } => catdir( $PConfig{build_dir}, $pmc_dir );
+
+
+ # find test files
+ find { no_chdir => 1,
+ wanted => sub{ files_of_type( [EMAIL PROTECTED],
$test_suffix ) },
+ } => catdir( $PConfig{build_dir}, $test_dir );
+
+
+ my( $pmc_miss, $test_miss ) = list_diff([EMAIL PROTECTED], [EMAIL
PROTECTED]);
+
+ local $" = "\n\t";
+
+
+ TODO: {
+ local $TODO = "not yet implemented";
+ ok([EMAIL PROTECTED], "there are test files for all PMC files
in $pmc_dir")
+ or diag "files in $test_dir but not in PMC dir:[EMAIL
PROTECTED]";
+
+ ok([EMAIL PROTECTED], "there are PMC files for all test files
in $test_dir")
+ or diag "files in $pmc_dir but not in test dir:[EMAIL
PROTECTED]";
+ }
+
+} # PMC
+
+
+# TODO: DYNPMC, DYNOPS, etc.
+
+
+# remember to change the number of tests :-)
+BEGIN { plan tests => 2; }
+
+
+
+exit;
+
+
+
+sub files_of_type
+{
+ my( $listref, $ext ) = @_;
+
+ return unless -f $File::Find::name
+ && $File::Find::name =~ m/\Q$ext\E$/;
+
+ my( $name, $path, $suffix ) =
+ fileparse( $File::Find::name, $ext );
+
+ push @$listref => $name;
+}
+
+
+sub list_diff
+{
+ my ($a, $b) = @_;
+
+ my %elem;
+ grep { $elem{$_}++ } @$a;
+ grep { $elem{$_}-- } @$b;
+
+ return (
+ [ sort grep { $elem{$_} < 0 } keys %elem ],
+ [ sort grep { $elem{$_} > 0 } keys %elem ],
+ );
+}
+