Skip Menu |

This queue is for tickets about the Filesys-Virtual-Chroot CPAN distribution.

Report information
The Basics
Id: 109040
Status: open
Priority: 0/
Queue: Filesys-Virtual-Chroot

People
Owner: Nobody in particular
Requestors: steveb [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Failing tests
Date: Mon, 16 Nov 2015 15:40:32 -0700
To: bug-Filesys-Virtual-Chroot [...] rt.cpan.org
From: Steve Bertrand <steve.bertrand [...] gmail.com>
I took a look as to why some of your tests are failing. Specifically on Windows, the $dir path was not the same as the $cr->rroot, as rroot has the path separators as forward slashes, where $dir had backslashes. To further that (on Windows), the "rmdir" command would fail because you're in that directory when you try to delete it, so I added a chdir() to go back to the original starting location when the test was started. I also took the liberty to upgrade your tests cases... using is() (from Test::More) will provide more valuable output on a failure than ok() will. If the patch doesn't fix the other failing tests (OSs that I don't have), the new t/02 tests that were failing should give some indication as to why. Cheers, Steve

Message body is not shown because sender requested not to inline it.

Had a couple of mistakes in the patch. This one is more effective.
Subject: fvc.patch
diff -urN Filesys-Virtual-Chroot-1.4/t/02vchdir.t Filesys-Virtual-Chroot-1.4-new/t/02vchdir.t --- Filesys-Virtual-Chroot-1.4/t/02vchdir.t 2015-11-14 16:24:16.000000000 -0700 +++ Filesys-Virtual-Chroot-1.4-new/t/02vchdir.t 2015-11-16 15:46:31.385484802 -0700 @@ -1,27 +1,45 @@ use strict; -use Test; +use Cwd; +use Test::More; use File::Temp qw/ tempfile tempdir /; +my $cwd = Cwd::cwd; my $dir = tempdir(); -BEGIN { plan tests => 7 } +BEGIN { plan tests => 9; } use Filesys::Virtual::Chroot; -my $cr; - -ok(eval { - $cr = Filesys::Virtual::Chroot->new( +my $cr = Filesys::Virtual::Chroot->new( c => $dir, - i => 0 - ) -}); + i => 0, +); + +is (ref $cr, 'Filesys::Virtual::Chroot', "object created ok"); + +is ($@, '', "created the object ok"); my $time = time; -ok($cr->rroot eq $dir); -ok($cr->vpwd eq '/'); -ok(mkdir "$dir/vchroot.$time", 0755); -ok($cr->vchdir("/vchroot.$time")); -ok($cr->rpwd eq "$dir/vchroot.$time"); -ok(rmdir "$dir/vchroot.$time"); +if ($^O eq 'MSWin32'){ + $dir =~ s|\\|/|g; +} + +is ($cr->rroot, $dir, "rroot is same as \$dir"); +is ($cr->vpwd, '/', "vpwd is / dir"); + +eval { + mkdir "$dir/vchroot.$time", 0755 or die $!; +}; + +is ($@, '', "\$time dir created ok"); + +$cr->vchdir("/vchroot.$time"); + +is ($cr->rpwd, "$dir/vchroot.$time", "changed into \$time dir ok"); + +chdir $cwd; +is (Cwd::cwd, $cwd, "changed into original dir location ok"); + +is (system("rmdir", "\"$dir/vchroot.$time\""), 0, "temp time dir removed ok"); +is (system("rmdir", "\"$dir\""), 0, "test chroot dir removed ok"); diff -urN Filesys-Virtual-Chroot-1.4/t/02vchdir.t~ Filesys-Virtual-Chroot-1.4-new/t/02vchdir.t~ --- Filesys-Virtual-Chroot-1.4/t/02vchdir.t~ 1969-12-31 17:00:00.000000000 -0700 +++ Filesys-Virtual-Chroot-1.4-new/t/02vchdir.t~ 2015-11-16 15:46:00.570034062 -0700 @@ -0,0 +1,45 @@ +use strict; +use Cwd; +use Test::More; +use File::Temp qw/ tempfile tempdir /; + +my $cwd = Cwd::cwd; +my $dir = tempdir(); + +BEGIN { plan tests => 8; } + +use Filesys::Virtual::Chroot; + +my $cr = Filesys::Virtual::Chroot->new( + c => $dir, + i => 0, +); + +is (ref $cr, 'Filesys::Virtual::Chroot', "object created ok"); + +is ($@, '', "created the object ok"); + +my $time = time; + +if ($^O eq 'MSWin32'){ + $dir =~ s|\\|/|g; +} + +is ($cr->rroot, $dir, "rroot is same as \$dir"); +is ($cr->vpwd, '/', "vpwd is / dir"); + +eval { + mkdir "$dir/vchroot.$time", 0755 or die $!; +}; + +is ($@, '', "\$time dir created ok"); + +$cr->vchdir("/vchroot.$time"); + +is ($cr->rpwd, "$dir/vchroot.$time", "changed into \$time dir ok"); + +chdir $cwd; +is (Cwd::cwd, $cwd, "changed into original dir location ok"); + +is (system("rmdir", "\"$dir/vchroot.$time\""), 0, "temp time dir removed ok"); +is (system("rmdir", "\"$dir\""), 0, "test chroot dir removed ok");
Thanks for checking into this, I tried your patch against my local system and noticed it's failing to remove the temporary directory. I'll play around with this a bit more and figure out whats going on. (unless you want to) -cf On Mon Nov 16 17:40:52 2015, steveb wrote: Show quoted text
> I took a look as to why some of your tests are failing. Specifically on > Windows, the $dir path was not the same as the $cr->rroot, as rroot has the > path separators as forward slashes, where $dir had backslashes. To further > that (on Windows), the "rmdir" command would fail because you're in that > directory when you try to delete it, so I added a chdir() to go back to the > original starting location when the test was started. > > I also took the liberty to upgrade your tests cases... using is() (from > Test::More) will provide more valuable output on a failure than ok() will. > If the patch doesn't fix the other failing tests (OSs that I don't have), > the new t/02 tests that were failing should give some indication as to why. > > Cheers, > > Steve