summaryrefslogtreecommitdiff
path: root/ext/File-Glob
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2014-04-06 20:07:05 +0100
committerDavid Mitchell <davem@iabyn.com>2014-04-06 20:07:05 +0100
commitdc9327d7b15505dbee4c9b53023efcfb88db6a8a (patch)
tree5276feeada4b21fd9f5073e1a6f2e63e72f31697 /ext/File-Glob
parentc67edbcd1a902e5bf297baff434c10fbfb3211db (diff)
downloadperl-dc9327d7b15505dbee4c9b53023efcfb88db6a8a.tar.gz
File-Glob/t/basic.t: avoid race condition
Test 2 does a glob('*') in the t/ directory, and compares that with the results of readdir('.'). If we're doing parallel testing, temporary files and stuff may get created in t/, resulting in a race condition and occasional random failures. Fix this by chdir()ing to t/base/ first. The timestamp on this directory on my system seems to indicate that nothing currently creates tmp files in that dir, and given that these are basic tests, that's relatively unlikely to change.
Diffstat (limited to 'ext/File-Glob')
-rw-r--r--ext/File-Glob/t/basic.t6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/File-Glob/t/basic.t b/ext/File-Glob/t/basic.t
index 78710753f9..2e6a4748d4 100644
--- a/ext/File-Glob/t/basic.t
+++ b/ext/File-Glob/t/basic.t
@@ -32,6 +32,11 @@ if ($^O eq 'VMS') {
# look for the contents of the current directory
+# try it in a directory that doesn't get modified during testing,
+# so parallel testing won't give us race conditions. t/base/ seems
+# fairly static
+
+chdir 'base' or die "chdir base: $!";
$ENV{PATH} = "/bin";
delete @ENV{qw(BASH_ENV CDPATH ENV IFS)};
my @correct = ();
@@ -46,6 +51,7 @@ if (GLOB_ERROR) {
} else {
is_deeply(\@a, \@correct);
}
+chdir '..' or die "chdir .. $!";
# look up the user's home directory
# should return a list with one item, and not set ERROR