Set initial commit timestamp to be constant.
[git-darcs-import.git] / tests / record_editor.pl
blob6ea05444f71a1996510008fb407584571eb299c3
1 #!/usr/bin/env perl
3 # Some tests for 'darcs rec --edit-long-comment'
5 use lib 'lib/perl';
6 use Test::More 'no_plan';
7 use Test::Darcs;
8 use strict;
9 use warnings;
10 use File::Path;
11 use File::Slurp;
12 use File::Temp 'tempdir';
13 chdir tempdir( CLEANUP => 1 );
15 my $GREP = `which grep`;
16 chomp $GREP;
18 sub init_dir {
19 my $d = shift;
20 my $dq = shift;
21 cleanup $d;
22 mkdir $d;
23 chdir $d;
24 darcs 'init';
25 write_file('file.t',"FIRST LINE\n");
26 darcs 'add file.t';
29 sub clean_dir {
30 my $d = shift;
31 chdir '../';
32 rmtree($d);
33 ok((!-d $d), 'temp1 directory was deleted');
36 $ENV{DARCS_EDITOR}="/bin/cat -n";
38 my $test_name = 'editor: space in command';
40 init_dir('temp1');
41 like(darcs('record --edit-long-comment -a -m foo file.t'), qr/2.*END OF DESCRIPTION/i, $test_name);
42 clean_dir('temp1');
44 $test_name = 'editor: space in path';
46 my $d = 'temp2 dir';
47 init_dir($d);
48 like(darcs('record --edit-long-comment -a -m foo file.t'), qr/2.*END OF DESCRIPTION/i, $test_name);
49 clean_dir($d);
52 $ENV{DARCS_EDITOR}=${GREP}.' "END OF"';
54 $test_name = 'editor: quoting in command';
56 init_dir('temp1','temp1');
57 like(darcs('record --edit-long-comment -a -m foo file.t'), qr/END OF/i, $test_name);
58 clean_dir('temp1','temp1');
60 $ENV{DARCS_EDITOR}='/bin/echo';
62 $test_name = 'editor: evil filename';
64 init_dir('temp1','temp1');
65 `touch '; test-command'`;
66 `printf "#!/bin/sh\necho EVIL" > test-command`;
67 `chmod u+x test-command`;
68 my $op = darcs(qw(record --logfile='; test-command' --edit-long-comment -a -m foo file.t));
69 unlike($op, qr/EVIL/i, $test_name);
70 clean_dir('temp1','temp1');