run_tests.pl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #! /usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use File::Spec::Functions qw/catdir catfile curdir abs2rel rel2abs/;
  5. use File::Basename;
  6. use Test::Harness qw/runtests $switches/;
  7. my $top = $ENV{TOP};
  8. my $recipesdir = catdir($top, "test", "recipes");
  9. my $testlib = catdir($top, "test", "testlib");
  10. my $utillib = catdir($top, "util");
  11. # It seems that $switches is getting interpreted with 'eval' or something
  12. # like that, and that we need to take care of backslashes or they will
  13. # disappear along the way.
  14. $testlib =~ s|\\|\\\\|g if $^O eq "MSWin32";
  15. $utillib =~ s|\\|\\\\|g if $^O eq "MSWin32";
  16. # Test::Harness provides the variable $switches to give it
  17. # switches to be used when it calls our recipes.
  18. $switches = "-w \"-I$testlib\" \"-I$utillib\"";
  19. my @tests = ( "alltests" );
  20. if (@ARGV) {
  21. @tests = @ARGV;
  22. }
  23. my $list_mode = scalar(grep /^list$/, @tests) != 0;
  24. if (grep /^alltests|list$/, @tests) {
  25. @tests = grep {
  26. basename($_) =~ /^[0-9][0-9]-[^\.]*\.t$/
  27. } glob(catfile($recipesdir,"*.t"));
  28. } else {
  29. my @t = ();
  30. foreach (@tests) {
  31. push @t, grep {
  32. basename($_) =~ /^[0-9][0-9]-[^\.]*\.t$/
  33. } glob(catfile($recipesdir,"*-$_.t"));
  34. }
  35. @tests = @t;
  36. }
  37. if ($list_mode) {
  38. @tests = map { $_ = basename($_); $_ =~ s/^[0-9][0-9]-//; $_ =~ s/\.t$//;
  39. $_ } @tests;
  40. print join("\n", @tests), "\n";
  41. } else {
  42. @tests = map { abs2rel($_, rel2abs(curdir())); } @tests;
  43. runtests(sort @tests);
  44. }