Tone down the requirements of a test that will go away.
[openssl.git] / test / recipes / 00-check_testexes.t
1 #! /usr/bin/perl
2
3 use strict;
4
5 use File::Spec::Functions;
6 use Test::More;
7
8 use OpenSSL::Test qw/:DEFAULT top_file/;
9
10 setup("check_testexes");
11
12 my $MINFO = top_file("MINFO");
13
14  SKIP: {
15      my %foundfiles;
16      my $numtests = 1;
17
18      if (open(FH,$MINFO)) {
19          while(<FH>) {
20              chomp;
21              last if /^RELATIVE_DIRECTORY=test$/;
22          }
23          while(<FH>) {
24              chomp;
25              last if /^EXE=/;
26          }
27          close FH;
28
29          my $pathfix = sub { return shift; }; # noop
30          if ($^O eq "MSWin32") {
31              # Experience has shown that glob needs the backslashes escaped
32              # to handle the glob glob() gets served.  Otherwise, it sometimes
33              # considers the backslash an escape of the next character, most
34              # notably the [.
35              # (if the single backslash is followed by a *, however, the *
36              # doesn't seem to be considered escaped...  go figure...)
37              $pathfix = sub { shift; s/\\/\\\\/g; return $_; };
38          }
39          s/^EXE=\s*//;
40          s/\s*$//;
41          %foundfiles =
42              map {
43                  my $key = $_;
44                  s/_?test$//;
45                  s/(sha\d+)t/$1/;
46                  $key =>
47                      $pathfix->(top_file("test", "recipes",
48                                          "[0-9][0-9]-test_$_.t")); } split(/\s+/, $_);
49          $numtests = scalar keys %foundfiles;
50      }
51
52      plan tests => $numtests;
53
54      skip "because $MINFO found. If you want this test to run, please do 'perl util/mkfiles.pl > $MINFO'", 1
55          unless %foundfiles;
56
57      foreach (sort keys %foundfiles) {
58          my @check = glob($foundfiles{$_});
59          ok(scalar @check, "check that a test for $_ exists")
60              || diag("Expected to find something matching $foundfiles{$_}");
61      }
62 }