File: record_editor.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 (70 lines) | stat: -rw-r--r-- 1,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
#!/usr/bin/env perl

# Some tests for 'darcs rec --edit-long-comment'

use lib 'lib/perl';
use Test::More 'no_plan';
use Test::Darcs;
use strict;
use warnings;
use File::Path;
use File::Slurp;
use File::Temp 'tempdir';
chdir tempdir( CLEANUP => 1 );

my $GREP  = `which grep`;
chomp $GREP;

sub init_dir {
  my $d = shift;
  my $dq = shift;
  cleanup $d;
  mkdir $d;
  chdir $d;
  darcs 'init';
  write_file('file.t',"FIRST LINE\n");
  darcs 'add file.t';
}

sub clean_dir {
  my $d = shift;
   chdir '../';
   rmtree($d);
   ok((!-d $d), 'temp1 directory was deleted');
}

$ENV{DARCS_EDITOR}="/bin/cat -n";

my $test_name = 'editor: space in command';

init_dir('temp1');
like(darcs('record --edit-long-comment -a -m foo file.t'), qr/2.*END OF DESCRIPTION/i, $test_name);
clean_dir('temp1');

$test_name = 'editor: space in path';

my $d = 'temp2 dir';
init_dir($d);
like(darcs('record --edit-long-comment -a -m foo file.t'), qr/2.*END OF DESCRIPTION/i, $test_name);
clean_dir($d);


$ENV{DARCS_EDITOR}=${GREP}.' "END OF"';

$test_name = 'editor: quoting in command';

init_dir('temp1','temp1');
like(darcs('record --edit-long-comment -a -m foo file.t'), qr/END OF/i, $test_name);
clean_dir('temp1','temp1');

$ENV{DARCS_EDITOR}='/bin/echo';

$test_name = 'editor: evil filename';

init_dir('temp1','temp1');
`touch '; test-command'`;
`printf "#!/bin/sh\necho EVIL" > test-command`;
`chmod u+x test-command`;
my $op = darcs(qw(record --logfile='; test-command' --edit-long-comment -a -m foo file.t));
unlike($op, qr/EVIL/i, $test_name);
clean_dir('temp1','temp1');