-
Notifications
You must be signed in to change notification settings - Fork 138
/
Parrot_Distribution.t
103 lines (75 loc) · 3.33 KB
/
Parrot_Distribution.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#! perl
# Copyright (C) 2001-2009, Parrot Foundation.
use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More tests => 26;
use File::Spec;
=head1 NAME
t/perl/Parrot_Distribution.t - Parrot::Distribution unit tests
=head1 SYNOPSIS
% prove t/perl/Parrot_Distribution.t
=head1 DESCRIPTION
Test individual Parrot::Distribution methods.
=cut
BEGIN { use_ok('Parrot::Distribution') }
die "Run these tests from the distribution root\n" unless -d 't/perl';
# search upwards
chdir 't/perl';
my $d = Parrot::Distribution->new();
isa_ok( $d, 'Parrot::Docs::Directory' );
ok( $d == Parrot::Distribution->new(), 'Parrot::Distribution is a singleton' );
ok( $d->c_source_file_with_name('pf_items'), 'C source file' );
ok( !$d->c_source_file_with_name('moomoo'), 'C source file not there' );
ok( $d->c_header_file_with_name('parrot'), 'C header file' );
ok( !$d->c_header_file_with_name('moomoo'), 'C header file not there' );
ok( $d->pmc_source_file_with_name('parrotinterpreter'), 'PMC code' );
ok( !$d->pmc_source_file_with_name('moomoo'), 'PMC code file not there' );
ok( $d->yacc_source_file_with_name('imcc'), 'Yacc code' );
ok( !$d->yacc_source_file_with_name('moomoo'), 'Yacc code file not there' );
ok( $d->lex_source_file_with_name('imcc'), 'Lex code' );
ok( !$d->lex_source_file_with_name('moomoo'), 'Lex code file not there' );
ok( $d->file_for_perl_module('Parrot::Docs::Section::Parrot'), 'Perl module file' );
ok( !$d->file_for_perl_module('Parrot::Dummy'), 'Perl module file not there' );
my %pmc_source_file_directories = map { $_->path => 1 } $d->pmc_source_file_directories();
my @old_directory_list = (
map { File::Spec->catdir( 'src', $_ ) } qw(dynpmc pmc)
);
for my $dir (@old_directory_list) {
my $path = $d->directory_with_name($dir)->path();
ok( exists $pmc_source_file_directories{$path},
"Directory from hardcoded list $dir found through MANIFEST" )
or diag( "Missing $dir\n" );
}
## perl files and exemptions
{
my @perl_files = $d->get_perl_language_files();
ok( @perl_files, 'Got some perl files' );
ok( $d->perl_source_file_with_name('ops2c.pl'), 'Perl source file (.pl)' );
ok( $d->perl_source_file_with_name('Distribution.pm'), 'Perl source file (.pm)' );
ok( $d->perl_source_file_with_name('perlcritic.t'), 'Perl source file (.t)' );
ok( !$d->perl_source_file_with_name('p5rx.t'), 'Not a Perl source file (.t)' );
my $perl_exemption_regexp = $d->get_perl_exemption_regexp();
ok( $perl_exemption_regexp, 'Got perl exemption regexp' );
# we are in 't/perl'
{
my $dummy_fn = '../../lib/DumbLink.pm';
my $not_exempted_file = Parrot::IO::File->new($dummy_fn);
ok( !$d->is_perl_exemption($not_exempted_file), 'DumbLink.pm is not exempted' );
unlike( $not_exempted_file->path(), $perl_exemption_regexp, 'DumbLink.pm is not matched' );
unlink $dummy_fn;
}
# check that no exemptions turn up in the main file list
my @exemptions_in_perl_list = grep { $_ =~ $perl_exemption_regexp }
map { $_->path } @perl_files;
ok( !@exemptions_in_perl_list, 'No exemptions in Perl source list' );
foreach (@exemptions_in_perl_list) {
diag("got exempted perl file: $_");
}
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: