X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDirHandle.t;h=35a7ea86c3d1dfd4224d97ee765d57613a61ed7b;hb=aaf9c2b26697492a8234a7efe890beef8868ea9b;hp=e83ea134965ec2e9f64db337ee24157809a158e4;hpb=b695f709e8a342e35e482b0437eb6cdacdc58b6b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/DirHandle.t b/lib/DirHandle.t index e83ea13..35a7ea8 100755 --- a/lib/DirHandle.t +++ b/lib/DirHandle.t @@ -11,24 +11,38 @@ BEGIN { } use DirHandle; +require './test.pl'; -print "1..5\n"; +plan(5); + +# Fetching the list of files in two different ways and expecting them +# to be the same is a race condition when tests are running in parallel. +# So go somewhere quieter. +my $chdir; +if ($ENV{PERL_CORE} && -d 'uni') { + chdir 'uni'; + $chdir++; +}; $dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.'); -print defined($dot) ? "ok" : "not ok", " 1\n"; +ok(defined($dot)); @a = sort <*>; do { $first = $dot->read } while defined($first) && $first =~ /^\./; -print +(grep { $_ eq $first } @a) ? "ok" : "not ok", " 2\n"; +ok(+(grep { $_ eq $first } @a)); @b = sort($first, (grep {/^[^.]/} $dot->read)); -print +(join("\0", @a) eq join("\0", @b)) ? "ok" : "not ok", " 3\n"; +ok(+(join("\0", @a) eq join("\0", @b))); $dot->rewind; @c = sort grep {/^[^.]/} $dot->read; -print +(join("\0", @b) eq join("\0", @c)) ? "ok" : "not ok", " 4\n"; +cmp_ok(+(join("\0", @b), 'eq', join("\0", @c))); $dot->close; $dot->rewind; -print defined($dot->read) ? "not ok" : "ok", " 5\n"; +ok(!defined($dot->read)); + +if ($chdir) { + chdir ".."; +}