Quellcode durchsuchen

Possible fix to windows CPANTesters failures from TR UTILS FIND

George S. Baugh vor 10 Jahren
Ursprung
Commit
2e656c5cea
1 geänderte Dateien mit 12 neuen und 8 gelöschten Zeilen
  1. 12 8
      lib/TestRail/Utils/Find.pm

+ 12 - 8
lib/TestRail/Utils/Find.pm

@@ -196,23 +196,27 @@ sub findTests {
     my $ext = $opts->{'extension'} // '';
 
     if ($opts->{'match'} || $opts->{'no-match'}) {
+        my @tmpArr = ();
         my $dir = $opts->{'match'} ? $opts->{'match'} : $opts->{'no-match'};
         if (!$opts->{'no-recurse'}) {
             File::Find::find( sub { push(@realtests,$File::Find::name) if -f && m/\Q$ext\E$/ }, $dir );
-            @tests = grep {my $real = $_->{'title'}; grep { $real eq basename($_) } @realtests} @cases; #XXX if you have dups in your tree, be-ware
         } else {
-            #Handle special windows case -- glob doesn't prepend abspath
             @realtests = glob("$dir/*$ext");
-            @tests = map {
-                $_->{'title'} = "$dir/".$_->{'title'} if( $^O eq 'MSWin32' );
-                $_
-            } grep {my $fname = $_->{'title'}; grep { basename($_) eq $fname} @realtests } @cases;
         }
+        foreach my $case (@cases) {
+            foreach my $path (@realtests) {
+                next unless $case->{'title'} eq basename($path);
+                $case->{'path'} = $path;
+                push(@tmpArr, $case);
+                last;
+            }
+        }
+        @tests = @tmpArr; #XXX if you have dups in your tree, be-ware
         @tests = map {{'title' => $_}} grep {my $otest = basename($_); scalar(grep {basename($_->{'title'}) eq $otest} @tests) == 0} @realtests if $opts->{'no-match'}; #invert the list in this case.
     }
 
-    @tests = map { abs_path($opts->{'match'}.'/'.$_->{'title'}) } @tests if $opts->{'match'} && $opts->{'names-only'};
-    @tests = map { $_->{'full_title'} = abs_path($opts->{'match'}.'/'.$_->{'title'}); $_ } @tests if $opts->{'match'} && !$opts->{'names-only'};
+    @tests = map { abs_path($_->{'path'}) } @tests if $opts->{'match'} && $opts->{'names-only'};
+    @tests = map { $_->{'full_title'} = abs_path($_->{'path'}); $_ } @tests if $opts->{'match'} && !$opts->{'names-only'};
     @tests = map { $_->{'title'} } @tests if !$opts->{'match'} && $opts->{'names-only'};
 
     return @tests;