File: set_scripts_executable.pl

package info (click to toggle)
darcs 2.0.2-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 6,400 kB
  • ctags: 1,048
  • sloc: haskell: 24,937; perl: 9,736; sh: 3,369; ansic: 1,913; makefile: 17; xml: 14
file content (73 lines) | stat: -rw-r--r-- 2,566 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env perl

# Some tests for the --set-scripts-executable option.

use lib 'lib/perl';
use Test::More 'no_plan';
use Test::Darcs;
use Shell::Command;
use strict;
use Cwd 'abs_path';

my $test_dir = abs_path();

if ($^O =~ /win/i) {
    pass 'test does not work on windows';
} else {
    my $test_name = 'darcs pull --set-scripts-executable works';

    use File::Temp 'tempdir';
    chdir tempdir( CLEANUP => 1 );

    mkpath 'temp1';
    chdir 'temp1';
    darcs 'init';

    cp "$test_dir/".__FILE__, 'script.pl' || die $!;
    chmod 0644, 'script.pl' || die $!;
    system 'date > nonscript';
    ok( (-r 'script.pl'), 'pre test: script exists and is readable' );
    ok( ! (-x 'script.pl'), 'pre test: script is not executable' );
    ok( (-r 'nonscript'), 'pre test: nonscript exists and is readable' );
    ok( ! (-x 'nonscript'), 'pre test: nonscript is not executable' );

    darcs  'add script.pl nonscript';
    like( ( darcs qw!record --patch-name 'uno' --all ! ), qr/finished recording/i );
    ok( chdir '..');
    # sans --set-scripts-executable (should not be executable)
    mkpath 'temp2';
    chdir 'temp2';
    darcs 'init';
    like( ( darcs qw%pull -a ../temp1 %) , qr/finished pulling/i );
    ok( (-r 'script.pl'), 'reality check: file has been pulled and is readable' );
    ok( (-r 'nonscript'), 'reality check: other file has been pulled and is readable' );

    ok(! (-x 'script.pl'), "nothing should be executable");
    ok(! (-x 'nonscript'), "nothing should be executable" );
    chdir '..';

    # darcs pull --set-scripts-executable
    cleanup 'temp2';
    mkpath 'temp2';
    chdir 'temp2';
    darcs 'init';
    like( ( darcs qw%pull --set-scripts-executable -a ../temp1 %) ,
           qr/finished pulling/i );
    ok( (-r 'script.pl'), 'reality check: file has been pulled and is readable' );
    ok( (-r 'nonscript'), 'reality check: other file has been pulled and is readable' );

    ok( (-x 'script.pl'), $test_name );
    ok(! (-x 'nonscript'), "innocent bystanders aren't set to be executable" );
    chdir '../';     # now outside of any repo

    # now let's try the same thing with get
    `rm -rf temp2`;
    like( darcs('get --set-scripts-executable temp1 temp2') ,
           qr/finished/i );
    chdir 'temp2';
    ok( (-r 'script.pl'), 'reality check: file has been gotten and is readable' );
    ok( (-r 'nonscript'), 'reality check: other file has been gotten and is readable' );

    ok( (-x 'script.pl'), $test_name );
    ok(! (-x 'nonscript'), "innocent bystanders aren't set to be executable" );
}