tidying
[exim.git] / test / listtests
1 #! /bin/sh
2
3 # This script scans the directories of Exim test scripts and lists the first
4 # comment line of each one, which gives a description. The output is piped via
5 # "more". If the script has an argument, it is a pattern that is used to select
6 # only certain subdirectories. If the script has a second argument, it is a
7 # pattern that is used to select only certain test titles from the selected
8 # directories.
9
10 /usr/bin/perl -w - "$1" "$2" <<'PerlEnd' | less
11
12 $dirpat = "$ARGV[0]";
13 $filpat = "$ARGV[1]";
14
15 opendir(SCRIPTS, "scripts") || die "** Failed to opendir(SCRIPTS): $!\n";
16 @subdirs = readdir(SCRIPTS);
17 closedir(SCRIPTS);
18
19 foreach $subdir (sort @subdirs)
20 {
21 my($first) = 1;
22
23 next if $subdir =~ /^\./;
24 next if $dirpat ne "" && $subdir !~ /$dirpat/i;
25
26 opendir(TESTS, "scripts/$subdir") ||
27 die "** Failed to opendir(scripts/$subdir): $!\n";
28 @tests = readdir(TESTS);
29 closedir(TESTS);
30
31 foreach $file (sort @tests)
32 {
33 next if $file !~ /^\d\d\d\d$/;
34
35 open(IN, "scripts/$subdir/$file") ||
36 die "** Failed to open scripts/$subdir/$file: $!\n";
37 my($heading) = substr(<IN>, 2);
38 close(IN);
39
40 if ($filpat eq "" || $heading =~ /$filpat/i)
41 {
42 if ($first)
43 {
44 print "\n=== $subdir ===\n";
45 if (open(REQUIRES, "scripts/$subdir/REQUIRES"))
46 {
47 my($indent) = "";
48 print "=== Requires: ";
49 while (<REQUIRES>)
50 {
51 print $indent, $_;
52 $indent = " ";
53 }
54 print "\n" if $indent eq "";
55 close (REQUIRES);
56 }
57 $first = 0;
58 }
59 printf("%s/%s %s", (substr $subdir, 5), $file, $heading);
60 }
61 }
62 }
63 PerlEnd
64
65 # End