X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fglob-basic.t;h=e8a2905addc05d21909365fd13b6a0c5570d56c9;hb=9ee2bb1a7c54b1866ff07ab9c157254810ee5205;hp=5189db458a9baf7ea07d0cad8728611558a34f93;hpb=72b166521443a1b89b0fed156fa8334cfab6e61b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/lib/glob-basic.t b/t/lib/glob-basic.t index 5189db4..e8a2905 100755 --- a/t/lib/glob-basic.t +++ b/t/lib/glob-basic.t @@ -2,14 +2,19 @@ BEGIN { chdir 't' if -d 't'; - unshift @INC, '../lib'; - + @INC = '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bFile\/Glob\b/i) { + print "1..0\n"; + exit 0; + } print "1..9\n"; } END { print "not ok 1\n" unless $loaded; } use File::Glob ':glob'; +use Cwd (); $loaded = 1; print "ok 1\n"; @@ -22,7 +27,7 @@ $ENV{PATH} = "/bin"; delete @ENV{BASH_ENV, CDPATH, ENV, IFS}; @correct = (); if (opendir(D, ".")) { - @correct = grep { !/^\.\.?$/ } sort readdir(D); + @correct = grep { !/^\./ } sort readdir(D); closedir D; } @a = File::Glob::glob("*", 0); @@ -34,18 +39,22 @@ print "ok 2\n"; # look up the user's home directory # should return a list with one item, and not set ERROR -if ($^O ne 'MSWin32') { +if ($^O ne 'MSWin32' && $^O ne 'VMS') { + eval { ($name, $home) = (getpwuid($>))[0,7]; - @a = File::Glob::glob("~$name", GLOB_TILDE); + 1; + } and do { + @a = bsd_glob("~$name", GLOB_TILDE); if (scalar(@a) != 1 || $a[0] ne $home || GLOB_ERROR) { print "not "; } + }; } print "ok 3\n"; # check backslashing # should return a list with one item, and not set ERROR -@a = File::Glob::glob('TEST', GLOB_QUOTE); +@a = bsd_glob('TEST', GLOB_QUOTE); if (scalar @a != 1 || $a[0] ne 'TEST' || GLOB_ERROR) { local $/ = "]["; print "# [@a]\n"; @@ -56,7 +65,7 @@ print "ok 4\n"; # check nonexistent checks # should return an empty list # XXX since errfunc is NULL on win32, this test is not valid there -@a = File::Glob::glob("asdfasdf", 0); +@a = bsd_glob("asdfasdf", 0); if ($^O ne 'MSWin32' and scalar @a != 0) { print "# |@a|\nnot "; } @@ -64,29 +73,36 @@ print "ok 5\n"; # check bad protections # should return an empty list, and set ERROR -$dir = "PtEeRsLt.dir"; -mkdir $dir, 0; -@a = File::Glob::glob("$dir/*", GLOB_ERR); -#print "\@a = ", array(@a); -rmdir $dir; -if (scalar(@a) != 0 || ($^O ne 'MSWin32' && GLOB_ERROR == 0)) { - print "not "; +if ($^O eq 'mpeix' or $^O eq 'MSWin32' or $^O eq 'os2' or $^O eq 'VMS' + or $^O eq 'cygwin' or Cwd::cwd() =~ m#^/afs#s or not $>) +{ + print "ok 6 # skipped\n"; +} +else { + $dir = "PtEeRsLt.dir"; + mkdir $dir, 0; + @a = bsd_glob("$dir/*", GLOB_ERR); + #print "\@a = ", array(@a); + rmdir $dir; + if (scalar(@a) != 0 || GLOB_ERROR == 0) { + print "not "; + } + print "ok 6\n"; } -print "ok 6\n"; # check for csh style globbing -@a = File::Glob::glob('{a,b}', GLOB_BRACE | GLOB_NOMAGIC); +@a = bsd_glob('{a,b}', GLOB_BRACE | GLOB_NOMAGIC); unless (@a == 2 and $a[0] eq 'a' and $a[1] eq 'b') { print "not "; } print "ok 7\n"; -@a = File::Glob::glob( +@a = bsd_glob( '{TES*,doesntexist*,a,b}', - GLOB_BRACE | GLOB_NOMAGIC + GLOB_BRACE | GLOB_NOMAGIC | ($^O eq 'VMS' ? GLOB_NOCASE : 0) ); unless (@a == 3 - and $a[0] eq 'TEST' + and $a[0] eq ($^O eq 'VMS'? 'test.' : 'TEST') and $a[1] eq 'a' and $a[2] eq 'b') { @@ -96,7 +112,7 @@ print "ok 8\n"; # "~" should expand to $ENV{HOME} $ENV{HOME} = "sweet home"; -@a = File::Glob::glob('~', GLOB_TILDE | GLOB_NOMAGIC); +@a = bsd_glob('~', GLOB_TILDE | GLOB_NOMAGIC); unless (@a == 1 and $a[0] eq $ENV{HOME}) { print "not "; }