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

[lintian] 01/01: t/runtests: Work around bug in perl5.18 (#723805)



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

nthykier pushed a commit to branch master
in repository lintian.

commit 92717965a6208b02dd38a8ffced46ffc39446cb0
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Sep 20 12:09:10 2013 +0200

    t/runtests: Work around bug in perl5.18 (#723805)
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 debian/changelog |    3 +++
 t/runtests       |   24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 70268cd..24cf88d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -139,6 +139,9 @@ lintian (2.5.18) UNRELEASED; urgency=low
 
   * t/runtests:
     + [NT] Assume dpkg (>= 1.16.1) is present.
+    + [NT] Work around bug in Perl (#723805) when using "glob"
+      within threads.  Thanks to Brian "hugmeir" Fraser for
+      finding the underlying cause.
   * t/tests/legacy-debug/debian/debian/control:
     + [NT] Mark some packages "arch:any" to avoid test failures
       on kfreebsd-amd64.  (Closes: #688524)
diff --git a/t/runtests b/t/runtests
index 5f5a633..d59719d 100755
--- a/t/runtests
+++ b/t/runtests
@@ -603,7 +603,11 @@ sub test_changes {
         # copy all files but "tags" and desc.  Usually this will only
         # be ".changes.in", but in rare cases we have "other files"
         # as well.
-        @files = grep { !/\.(?:desc|tags)$/o } glob "$testdir/$test.*";
+        #
+        # the _glob-call emulates glob("$testdir/$test.*")
+        # (see #723805)
+        @files
+          = grep { !/\.(?:desc|tags)$/o } _glob($testdir, qr/\Q$test.\E.*/);
         runsystem('cp', '-f', @files, "$RUNDIR/");
         $file = "$RUNDIR/${test}.changes";
         fill_in_tmpl($file, $testdata);
@@ -713,7 +717,9 @@ sub generic_test_runner {
         dump_log($testname, "$RUNDIR/build.$testname") if $DUMP_LOGS;
         fail("cd $targetdir && fakeroot make >../build.$testname 2>&1");
     }
-    my @matches = glob "$targetdir/*.$ext";
+    # The _glob call emulates glob("$targetdir/*.$ext")
+    # (see #723805)
+    my @matches = _glob($targetdir, qr/.*\.\Q$ext\E/);
     my $file = shift @matches;
     unless ($file && -e $file) {
         $file //= '<N/A>';
@@ -728,6 +734,20 @@ sub generic_test_runner {
     return _check_result($testdata, "$testdir/tags", "$RUNDIR/tags.$testname");
 }
 
+# Makeshift replacement for "glob" to work around #723805
+sub _glob {
+    my ($dir, $pattern) = @_;
+    my @matches;
+    opendir(my $dirfd, $dir);
+    for my $file (readdir($dirfd)) {
+        next if $file eq '.' or $file eq '..';
+        push(@matches, "$dir/$file")
+          if $file =~ m{\A $pattern \Z}xsm;
+    }
+    closedir($dirfd);
+    return @matches;
+}
+
 sub _check_result {
     my ($testdata, $expected, $actual, $origexp) = @_;
     # Compare the output to the expected tags.

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


Reply to: