Better method of skipping all the tests in 00-check_testexes.t
[openssl.git] / test / recipes / 00-check_testexes.t
index 5f8f1138ccb824b370fc432300095d38644e8f34..483d8830fe196c461b7dfba20788fdc0f5a66941 100644 (file)
@@ -3,60 +3,41 @@
 use strict;
 
 use File::Spec::Functions;
-use Test::More;
-
+use File::Basename;
 use OpenSSL::Test qw/:DEFAULT top_file/;
 
 setup("check_testexes");
 
 my $MINFO = top_file("MINFO");
 
- SKIP: {
-     my %foundfiles;
-     my $numtests = 1;
-
-     if (open(FH,$MINFO)) {
-        while(<FH>) {
-            chomp;
-            last if /^RELATIVE_DIRECTORY=test$/;
-        }
-        while(<FH>) {
-            chomp;
-            last if /^EXE=/;
-        }
-        close FH;
-
-        my $pathfix = sub { return shift; }; # noop
-        if ($^O eq "MSWin32") {
-            # Experience has shown that glob needs the backslashes escaped
-            # to handle the glob glob() gets served.  Otherwise, it sometimes
-            # considers the backslash an escape of the next character, most
-            # notably the [.
-            # (if the single backslash is followed by a *, however, the *
-            # doesn't seem to be considered escaped...  go figure...)
-            $pathfix = sub { shift; s/\\/\\\\/g; return $_; };
-        }
-        s/^EXE=\s*//;
-        s/\s*$//;
-        %foundfiles =
-            map {
-                my $key = $_;
-                s/_?test$//;
-                s/(sha\d+)t/$1/;
-                $key =>
-                    $pathfix->(top_file("test", "recipes",
-                                        "[0-9][0-9]-test_$_.t")); } split(/\s+/, $_);
-        $numtests = scalar keys %foundfiles;
-     }
-
-     plan tests => $numtests;
-
-     skip "because $MINFO found. If you want this test to run, please do 'perl util/mkfiles.pl > $MINFO'", 1
-        unless %foundfiles;
-
-     foreach (sort keys %foundfiles) {
-        my @check = glob($foundfiles{$_});
-        ok(scalar @check, "check that a test for $_ exists")
-            || diag("Expected to find something matching $foundfiles{$_}");
-     }
+plan skip_all => "because MINFO not found. If you want this test to run, please do 'perl util/mkfiles.pl > MINFO'"
+    unless open(FH,$MINFO);
+
+while(<FH>) {
+    chomp;
+    last if /^RELATIVE_DIRECTORY=test$/;
+}
+while(<FH>) {
+    chomp;
+    last if /^EXE=/;
+}
+close FH;
+
+s/^EXE=\s*//;
+s/\s*$//;
+my @expected_tests =
+    map { s/\..*$//;           # Remove extension
+         s/_?test$//;          # Remove 'test', possibly prefixed with '_'
+         s/(sha\d+)t/$1/;      # sha comes with no t at the end
+         $_; } split(/\s+/, $_);
+
+plan tests => scalar @expected_tests;
+
+my @found_tests =
+    map { basename($_) } glob(top_file("test", "recipes", "*.t"));
+
+foreach my $test (sort @expected_tests) {
+    ok(scalar(grep(/^[0-9][0-9]-test_$test\.t$/, @found_tests)),
+       "check that a test for $test exists")
+       || diag("Expected to find something matching '[0-9][0-9]-test_$test.t'");
 }