Made committer details and time = author details and time
[git-darcs-import.git] / tests / add.pl
blob4e9d5457652d840983bd73be63b3246b05b52b25
1 #!/usr/bin/env perl
3 # Some tests for 'darcs add'
5 use lib 'lib/perl';
6 use Test::More 'no_plan';
7 use Test::Darcs;
8 use Shell::Command;
9 use strict;
10 use warnings;
12 init_tmp_repo();
14 ###
16 my $test_name = 'Make sure that messages about directories call them directories.';
17 mkpath 'foo.d';
18 mkpath 'oof.d';
19 darcs qw( add foo.d );
20 darcs qw( add oof.d );
21 # Try adding the same directory when it's already in the repo
22 like(darcs(qw( add foo.d )), qr/directory/,$test_name);
23 like(darcs(qw( add foo.d oof.d )), qr/directories/,$test_name);
25 ###
27 $test_name = 'Make sure that messages about files call them files.';
28 touch 'bar';
29 touch 'baz';
30 darcs qw( add bar ) ;
31 darcs qw( add baz ) ;
32 like(darcs(qw( add bar )), qr/following file is/, $test_name);
33 like(darcs(qw( add bar baz )), qr/following files are/, $test_name);
35 ###
37 $test_name = 'Make sure that messages about both files and directories say so.';
38 like(darcs(qw( add bar foo.d )), qr/files and directories/, $test_name);
40 ###
42 $test_name = 'Make sure that parent directories are added for files.';
43 mkpath 'a.d/aa.d/aaa.d';
44 mkpath 'b.d/bb.d';
45 touch 'a.d/aa.d/aaa.d/baz';
46 touch 'a.d/aa.d/aaa.d/bar';
47 like(darcs(qw( add a.d/aa.d/aaa.d/bar a.d/aa.d/aaa.d/baz b.d/bb.d )), qr/^$/, $test_name);
48 ###
50 $test_name = 'Make sure that darcs doesn\'t complains about duplicate adds when adding parent dirs.';
51 mkpath 'c.d/';
52 touch 'c.d/baz';
53 like(darcs(qw( add c.d/baz c.d )), qr/^$/, $test_name);
55 ###
57 $test_name = 'Make sure that add output looks good when adding files in subdir.';
58 mkpath 'd.d/';
59 touch 'd.d/foo';
60 like(darcs(qw(add -rv d.d)), qr/d.d\/foo/,$test_name);
62 TODO: {
63 local $TODO = 'waiting on coding';
64 my $test_name = "add should fail on files it can't read (because it would fail to record it later anyway).";
65 touch "no_perms.txt";
66 chmod(0000,"no_perms.txt");
67 like(darcs(qw(add no_perms.txt)), qr/permission denied/,$test_name);
68 rm_rf "no_perms.txt";
74 my $test_name = 'adding a non-existent dir and file gives the expected message';
75 my $out = darcs(qw!add notadir/notafile!);
76 like($out,qr/does not exist/i,$test_name);
79 chdir '../';