[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/01: t/runtests: Avoid some unnecessary fork+exec



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit cd3c1e7717d4d09a39a5551ee5959a9300e5840d
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Sep 23 09:40:40 2017 +0000

    t/runtests: Avoid some unnecessary fork+exec
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 t/runtests | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/t/runtests b/t/runtests
index 6d8ce03..10ba105 100755
--- a/t/runtests
+++ b/t/runtests
@@ -33,6 +33,7 @@ use autodie;
 use Carp qw(confess);
 use Cwd();
 
+use File::Path qw(make_path);
 use Getopt::Long qw(GetOptions);
 use IO::Async::Channel;
 use IO::Async::Loop;
@@ -363,7 +364,7 @@ sub test_package {
 
         $test_state->info_msg(2, "Cleaning up and repopulating $targetdir...");
         runsystem_ok('rm', '-rf', $rundir);
-        runsystem_ok('mkdir', '-p', $rundir);
+        make_path($rundir);
         unless ($is_native) {
             copy_template_dir("$tmpldir/${skel}.upstream",
                 "$origdir/upstream/",$targetdir);
@@ -547,10 +548,10 @@ sub test_changes {
         }
     }
 
-    # Use mkdir -p to avoid a race condition where two threads tries
-    # to create the same dir and then have one of them error out.
-    runsystem_ok('mkdir', '-p', "$RUNDIR/changes")
-      if not -d "$RUNDIR/changes";
+    # make_path supports "mkdir -p"-like behaviour where even if multiple
+    # threads can race to create the directory, they will all return
+    # "successful".
+    make_path("$RUNDIR/changes") if not -d "$RUNDIR/changes";
 
     $test_state->progress('setup');
 
@@ -617,7 +618,7 @@ sub generic_test_runner {
 
         $test_state->info_msg(2, "Cleaning up and repopulating $targetdir...");
         runsystem_ok('rm', '-rf', $targetdir);
-        runsystem_ok('mkdir', '-p', $targetdir);
+        make_path($targetdir);
         runsystem('cp', '-rp', $testdir, $targetdir);
 
         copy_template_dir("$tmpldir/$skel", "$testdir/", $targetdir,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: