File: testDocumentation

package info (click to toggle)
gnump3d 2.9.3-1sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,420 kB
  • ctags: 366
  • sloc: perl: 10,649; sh: 188; makefile: 147
file content (100 lines) | stat: -rwxr-xr-x 1,761 bytes parent folder | download
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
#!/usr/bin/perl 
# Test that every configuration option is documented in 'man gnump3d.conf'.
#
#  (This is a scary test!)
#

#
#  A hash of keys which don't need to be documented.
#
my %EXCEPTIONS;
$EXCEPTIONS{ "plugin_bug" }      = 1;
$EXCEPTIONS{ "plugin_last" }     = 1;
$EXCEPTIONS{ "plugin_playlist" } = 1;
$EXCEPTIONS{ "plugin_search" }   = 1;
$EXCEPTIONS{ "plugin_stats" }    = 1;
$EXCEPTIONS{ "plugin_theme" }    = 1;
$EXCEPTIONS{ "plugin_now" }      = 1;


my $configFile = "../etc/gnump3d.conf";

open( CONFIG, "<$configFile" ) or die "Cannot read configuration file: $!";
my @lines = <CONFIG>;
close( CONFIG );

my %KEYS;

foreach my $line ( @lines )
{
    chomp( $line );

    if ( $line =~ /([^=]+)=(.*)/ )
    {
	my $key = $1;
	my $val = $2;

	if ( $key =~ /^#[ \t]+(.*)/ )
	{
	    $key = $1;
	}

	# Strip leading and trailing whitespace.
	$key =~ s/^\s+//;
	$key =~ s/\s+$//;
	$val =~ s/^\s+//;
	$val =~ s/\s+$//;

	if ( $key =~ /^#(.*)/ ) { $key = $1; }

	# Skip keys starting with '$' - this is a bug in the script.
	next if ( $key =~ /^\$/ );

	$KEYS{ $key } = $val;
    }
}


#
#  Read in our man page
#
open( MANPAGE, "../man/gnump3d.conf.1" ) or die "Cannot open manpage: $!";
my @DOCUMENTATION = <MANPAGE>;
close( MANPAGE );

#
#  Remove any exceptions we might have.
#
foreach my $undocumented (keys ( %EXCEPTIONS ) )
{
    delete( $KEYS{ $undocumented } );
}

#
#  Now that we have a line test that the man page expects it.
#
my $failed = 0;
foreach my $key (sort( keys( %KEYS ) ) )
{
    my $found = 0;
    foreach my $line ( @DOCUMENTATION )
    {
	if ( $line =~ /$key/ ) 
	{
	    $found += 1;
	}
    }

    if ( $found eq 0 )
    {
	$failed += 1;
	print "Key '$key' not documented\n";
    }
}

if ( $failed )
{
    exit 1;
}

exit 0;