diff --git a/ChangeLog b/ChangeLog index 13266cc68..a578b3826 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-24 Guillaume Sadegh + + * src/sanity/readme.test: A script to check whether all the + directories referenced in README exist. + * src/sanity/Makefile.am: Adjust to call `readme.test' when make + check is invoked. + 2010-01-24 Guillaume Sadegh Update the README. diff --git a/src/sanity/Makefile.am b/src/sanity/Makefile.am index 2a12cae33..d787cb62a 100644 --- a/src/sanity/Makefile.am +++ b/src/sanity/Makefile.am @@ -34,6 +34,8 @@ check-local: $(SHELL) $(srcdir)/80columns.test $(TESTHEADER) INCDIR='$(top_srcdir)/src' \ $(SHELL) $(srcdir)/style.test $(TESTHEADER) + top_srcdir='$(top_srcdir)' \ + $(PERL) $(srcdir)/readme.test # Ensure we have not forgotten to include an header. installcheck-local: diff --git a/src/sanity/readme.test b/src/sanity/readme.test new file mode 100755 index 000000000..553ee9489 --- /dev/null +++ b/src/sanity/readme.test @@ -0,0 +1,57 @@ +#! /usr/bin/perl -w +# -*- cperl -*- + +# Check that all the directories in the README exist. +# Also has an option --list to print directories which are +# documented in the README. + +use strict; +use warnings; + +local $\ = "\n"; +my $top_srcdir = $ENV{top_srcdir} || "../../"; +my $list_mode = ($#ARGV != -1 && $ARGV[0] eq "--list"); + +unless (-f "$top_srcdir/README") +{ + print STDERR "$top_srcdir/README not found"; + exit 2; +} + +open(FD, "$top_srcdir/README"); +my @directory = (); +my $exit_status = 0; + +while () +{ + # We consider Third party software? + # last if (/^Third party software$/); + next unless (m{^(\s*)(\S+/)\s+}); + my $level = length($1) / 3; + my $name = $2; + + $directory[$level] = $name; + $#directory = $level; + my $filename = join "", @directory; + + # Use globbing on the filename. + for my $directory (glob("$top_srcdir/$filename")) + { + if ($list_mode) + { + print "$directory"; + } + else + { + unless (-d $directory || -f $directory) + { + print STDERR "$directory does not exist."; + $exit_status = 1; + } + } + } +} + +close(FD); + +exit $exit_status;