vsespb has asked for the wisdom of the Perl Monks concerning the following question:
and somefunc() looks like this:use strict; use warnings; use Test::More tests => 2; my $file = 'somefile.tmp'; unlink $file; open my $f, '>', $file; close $f; chmod 0000, $file; SKIP: { skip "cannot run under root", 2 unless $<; ok ! eval { somefunc($file); 1; }; ok $@ =~ /cannot open file/; } unlink $file;
(that is a simplified version too - just for proof of concept)sub somefunc { open my $f, "<", shift or die 'cannot open file' };
That's because otherwise test will fail under root.skip "cannot run under root", 2 unless $<;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check for root under Cygwin
by syphilis (Archbishop) on Sep 02, 2013 at 11:59 UTC | |
by vsespb (Chaplain) on Sep 02, 2013 at 12:04 UTC | |
by syphilis (Archbishop) on Sep 02, 2013 at 12:29 UTC | |
by vsespb (Chaplain) on Sep 02, 2013 at 13:17 UTC | |
by vsespb (Chaplain) on Sep 02, 2013 at 12:45 UTC | |
|
Re: Check for root under Cygwin
by Laurent_R (Canon) on Sep 02, 2013 at 11:36 UTC | |
by vsespb (Chaplain) on Sep 02, 2013 at 11:53 UTC |