[Rt-commit] rt branch, 4.0/policy-race-condition, created. rt-4.0.19-17-g3b1dfdc

Alex Vandiver alexmv at bestpractical.com
Tue Feb 11 20:10:54 EST 2014


The branch, 4.0/policy-race-condition has been created
        at  3b1dfdcb1f9adcd1fbc86e8748b85cc94511f98f (commit)

- Log -----------------------------------------------------------------
commit 3b1dfdcb1f9adcd1fbc86e8748b85cc94511f98f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Feb 11 20:07:13 2014 -0500

    Prevent race conditions under t/tmp/, and descending into .git dirs
    
    The find() call in t/99-policy.y descends into t/, which includes
    t/tmp/, which is a directory in active use by other test processes.
    This allows a race condition between when find() lists the
    subdirectories of t/tmp/, and when it later tries to open a subdirectory
    within it.  In the intervening time, the test responsible for the
    subdirectory may have removed it, causing:
    
        Can't opendir(t/tmp/api-attachment.t-MQmEJUkg): No such file or directory
    
    Prune the t/tmp directory and its contents, to prevent this race
    condition.  Also prune any .git repositories which may reside within it,
    such as the security test repository.

diff --git a/t/99-policy.t b/t/99-policy.t
index f4b80e8..39aa448 100644
--- a/t/99-policy.t
+++ b/t/99-policy.t
@@ -5,9 +5,13 @@ use RT::Test;
 use File::Find;
 
 my @files;
-find( { wanted   => sub { push @files, $File::Find::name if -f },
+find( { wanted   => sub {
+            push @files, $File::Find::name if -f;
+            $File::Find::prune = 1 if $_ eq "t/tmp" or m{/\.git$};
+        },
         no_chdir => 1 },
       qw{etc lib share t bin sbin devel/tools} );
+
 if ( my $dir = `git rev-parse --git-dir 2>/dev/null` ) {
     # We're in a git repo, use the ignore list
     chomp $dir;

-----------------------------------------------------------------------


More information about the rt-commit mailing list