Made committer details and time = author details and time
[git-darcs-import.git] / tests / set_scripts_executable.pl
bloba81921ef846243ec54b9315927187c30f0f85b1e
1 #!/usr/bin/env perl
3 # Some tests for the --set-scripts-executable option.
5 use lib 'lib/perl';
6 use Test::More 'no_plan';
7 use Test::Darcs;
8 use Shell::Command;
9 use strict;
10 use Cwd 'abs_path';
12 my $test_dir = abs_path();
14 if ($^O =~ /win/i) {
15 pass 'test does not work on windows';
16 } else {
17 my $test_name = 'darcs pull --set-scripts-executable works';
19 use File::Temp 'tempdir';
20 chdir tempdir( CLEANUP => 1 );
22 mkpath 'temp1';
23 chdir 'temp1';
24 darcs 'init';
26 cp "$test_dir/".__FILE__, 'script.pl' || die $!;
27 chmod 0644, 'script.pl' || die $!;
28 system 'date > nonscript';
29 ok( (-r 'script.pl'), 'pre test: script exists and is readable' );
30 ok( ! (-x 'script.pl'), 'pre test: script is not executable' );
31 ok( (-r 'nonscript'), 'pre test: nonscript exists and is readable' );
32 ok( ! (-x 'nonscript'), 'pre test: nonscript is not executable' );
34 darcs 'add script.pl nonscript';
35 like( ( darcs qw!record --patch-name 'uno' --all ! ), qr/finished recording/i );
36 ok( chdir '..');
37 # sans --set-scripts-executable (should not be executable)
38 mkpath 'temp2';
39 chdir 'temp2';
40 darcs 'init';
41 like( ( darcs qw%pull -a ../temp1 %) , qr/finished pulling/i );
42 ok( (-r 'script.pl'), 'reality check: file has been pulled and is readable' );
43 ok( (-r 'nonscript'), 'reality check: other file has been pulled and is readable' );
45 ok(! (-x 'script.pl'), "nothing should be executable");
46 ok(! (-x 'nonscript'), "nothing should be executable" );
47 chdir '..';
49 # darcs pull --set-scripts-executable
50 cleanup 'temp2';
51 mkpath 'temp2';
52 chdir 'temp2';
53 darcs 'init';
54 like( ( darcs qw%pull --set-scripts-executable -a ../temp1 %) ,
55 qr/finished pulling/i );
56 ok( (-r 'script.pl'), 'reality check: file has been pulled and is readable' );
57 ok( (-r 'nonscript'), 'reality check: other file has been pulled and is readable' );
59 ok( (-x 'script.pl'), $test_name );
60 ok(! (-x 'nonscript'), "innocent bystanders aren't set to be executable" );
61 chdir '../'; # now outside of any repo
63 # now let's try the same thing with get
64 `rm -rf temp2`;
65 like( darcs('get --set-scripts-executable temp1 temp2') ,
66 qr/finished/i );
67 chdir 'temp2';
68 ok( (-r 'script.pl'), 'reality check: file has been gotten and is readable' );
69 ok( (-r 'nonscript'), 'reality check: other file has been gotten and is readable' );
71 ok( (-x 'script.pl'), $test_name );
72 ok(! (-x 'nonscript'), "innocent bystanders aren't set to be executable" );