3 # Some tests for proper handling of filepaths
6 use Test
::More
'no_plan';
12 use File
::Temp
'tempdir';
13 my $work_dir = tempdir
( CLEANUP
=> 1 );
18 my $repo_flag = '--repodir=temp1';
19 my $test_name = 'Make sure that init works with --repodir';
20 darcs
"init $repo_flag";
21 ok
((-d
'temp1/_darcs'), '_darcs directory was created');
23 # add some meat to that repository
27 darcs
qw( record -m moo -a ) ;
30 # ----------------------------------------------------------------------
31 # local vs remote filepaths
32 # ----------------------------------------------------------------------
33 like
( darcs
("get temp1 temp2"), qr/Finished getting/i );
39 unlike
( darcs
("add foo:bar"), qr/failed/i );
43 # ----------------------------------------------------------------------
45 # ----------------------------------------------------------------------
46 mkpath
'temp1/non-darcs';
47 $test_name = '--repodir is not recursive';
48 like
( darcs
("get temp1/non-darcs"), qr
/Not a repository
/i
, $test_name );
49 cleanup
'temp1/non-darcs';
52 $test_name = 'get accepts --repodir.';
53 like
( darcs
("get --repodir=temp2 temp1"), qr/Finished getting/i, $test_name );
54 ok
((-d
'temp2/_darcs'), '_darcs directory was created');
56 $test_name = 'get accepts absolute --repodir.';
57 like
( darcs
(q{get --repodir="}.cwd
().q{/temp2" temp1}), qr
/Finished getting
/i
, $test_name );
58 ok
((-d
'temp2/_darcs'), '_darcs directory was created');
60 $test_name = 'changes accepts --repodir.';
61 like
( darcs
("changes $repo_flag"), qr/moo/i, $test_name );
62 $test_name = 'changes accepts absolute --repo.';
63 like
( darcs
(q{changes --repo="}.cwd
().q{/temp1"}), qr
/moo
/i
, $test_name );
64 $test_name = 'changes accepts relative --repo.';
65 like
( darcs
("changes --repo=temp1"), qr/moo/i, $test_name );
66 $test_name = "[issue467] context --repodir";
67 like
( darcs
("changes --context --repodir=temp1"), qr/Context:/, $test_name );
69 $test_name = 'dist accepts --repodir.';
70 like
( darcs
("dist $repo_flag"), qr/Created dist/i, $test_name );
72 $test_name = 'optimize accepts --repodir.';
73 like
( darcs
("optimize --reorder-patches $repo_flag"), qr/done optimizing/i, $test_name );
75 $test_name = 'repair accepts --repodir.';
76 like
( darcs
("repair $repo_flag"), qr/already consistent/i, $test_name );
78 $test_name = 'replace accepts --repodir.';
79 like
( darcs
("replace $repo_flag foo bar"), qr//i, $test_name );
81 $test_name = 'setpref accepts --repodir.';
82 like
( darcs
("setpref $repo_flag test echo"), qr/Changing value of test/i, $test_name );
84 $test_name = 'trackdown accepts --repodir.';
85 like
( darcs
("trackdown $repo_flag"), qr/Success!/i, $test_name );
87 # ----------------------------------------------------------------------
88 # converting between absolute and relative paths
89 # ----------------------------------------------------------------------
91 like
( darcs
("get temp1 temp3"), qr/Finished getting/i );
96 sub change_something_record
{
99 print BAZ
"hello $hello";
101 darcs
("record -m hello$hello -a");
104 change_something_record
1;
105 change_something_record
2;
108 $test_name = 'can handle .. path';
110 like
( darcs
("pull ../temp2 -p1 --all"), qr
/Finished pulling
/, $test_name );
111 like
( darcs
("pull --dry-run"), qr/hello2/, "$test_name with defaultrepo" );
113 like
( darcs
("pull --dry-run"), qr/hello2/, "[issue268] $test_name with subdir" );