Skip to content

Commit

Permalink
SKIP if the permissions cannot be modified
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Mar 27, 2008
1 parent 06480ec commit 54d022c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
26 changes: 17 additions & 9 deletions t/file-permission.t
Expand Up @@ -8,8 +8,10 @@ use Test::More;
use lib 't';
use Util;

use constant NTESTS => 10;

plan skip_all => q{Can't be checked under Win32} if is_win32;
plan tests => 10;
plan tests => NTESTS;

prep_environment();

Expand All @@ -19,16 +21,22 @@ my $program = $0;
my $old_mode;
(undef, undef, $old_mode) = stat($program);
my $nchanged = chmod 0000, $program;
is( $nchanged, 1, sprintf( 'chmodded %s to 0000 from %o', $program, $old_mode ) );

# execute a search on this file
check_with( 'regex', $program );
# --count takes a different execution path
check_with( 'regex', '--count', $program );
SKIP: {
skip q{Unable to modify test program's permissions}, NTESTS unless $nchanged;

is( $nchanged, 1, sprintf( 'chmodded %s to 0000 from %o', $program, $old_mode ) );

# execute a search on this file
check_with( 'regex', $program );

# change permissions back
chmod $old_mode, $program;
is( $nchanged, 1, sprintf( 'chmodded %s back to %o', $program, $old_mode ) );
# --count takes a different execution path
check_with( 'regex', '--count', $program );

# change permissions back
chmod $old_mode, $program;
is( $nchanged, 1, sprintf( 'chmodded %s back to %o', $program, $old_mode ) );
}

sub check_with {
local $Test::Builder::Level = $Test::Builder::Level + 1;
Expand Down
2 changes: 2 additions & 0 deletions tags
Expand Up @@ -104,6 +104,7 @@ NO_O t/ack-o.t /^NO_O: {$/;" l
NO_STARTDIR t/ack-g.t /^NO_STARTDIR: {$/;" l
NO_SWITCHES_MULTIPLE_FILES t/ack-h.t /^NO_SWITCHES_MULTIPLE_FILES: {$/;" l
NO_SWITCHES_ONE_FILE t/ack-h.t /^NO_SWITCHES_ONE_FILE: {$/;" l
NTESTS t/file-permission.t /^use constant NTESTS => 10;$/;" c
ONLY_MAKEFILES t/ack-g.t /^ONLY_MAKEFILES: {$/;" l
PARROT_FILES_DESCEND t/interesting.t /^PARROT_FILES_DESCEND: {$/;" l
PARROT_FILES_NODESCEND t/interesting.t /^PARROT_FILES_NODESCEND: {$/;" l
Expand All @@ -125,6 +126,7 @@ SINGLE_TEXT_MATCH_ENV t/ack-env.t /^SINGLE_TEXT_MATCH_ENV: {$/;" l
SINGLE_TEXT_MATCH_NOENV t/ack-env.t /^SINGLE_TEXT_MATCH_NOENV: {$/;" l
SKIP t/ack-passthru.t /^ SKIP: {$/;" l
SKIP t/context.t /^ SKIP: {$/;" l
SKIP t/file-permission.t /^SKIP: {$/;" l
SPECIFYING_A_BAK_FILE t/command-line-files.t /^SPECIFYING_A_BAK_FILE: {$/;" l
STANDARD_GROUPING t/ack-group.t /^STANDARD_GROUPING: {$/;" l
STARTING_POINTS t/module.t /^STARTING_POINTS: {$/;" l
Expand Down

0 comments on commit 54d022c

Please sign in to comment.