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