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

# Some tests for 'darcs put' 

use lib 'lib/perl';
use Test::More 'no_plan';
use Test::Darcs;
use Shell::Command;
use Cwd;
use strict;
use File::Temp 'tempdir';
chdir tempdir( CLEANUP => 1 );

cleanup  qw/temp1 temp2/;
mkpath 'temp1';
chdir 'temp1';
darcs 'init';
chdir '../';

{
  my $test_name = 'put should set default repo';
  chdir './temp1';
  touch '1.txt';
  darcs qw/add 1.txt/;
  darcs (qw/record -a -m foo 1.txt/);
  darcs (qw% put ../temp2 %);
  
  my $default_repo;
  if (ok(open(DEFAULT_REPO,'<_darcs/prefs/defaultrepo'),"put populates defaultrepo")) {
    $default_repo = (<DEFAULT_REPO>);
    close(DEFAULT_REPO);
  }
  
  like($default_repo,qr/temp2/,$test_name);
  chdir '../';
}


SELF_PUT: {
    chdir './temp1'; 

    my $default_repo_pre_test = 'Before trying to put from self, defaultrepo is something else';
    my $default_repo;
    if (open(DEFAULT_REPO,'<./_darcs/prefs/defaultrepo')) {
      $default_repo = (<DEFAULT_REPO>);
      close(DEFAULT_REPO);
    }

    unlike($default_repo,qr/temp1/,$default_repo_pre_test);

    my $test_name = 'return special message when you try to put put yourself';
    my $abs_path = cwd();
    my $out = darcs "put $abs_path";
    like($out , qr/Can't put.*current repository!/i, $test_name);

    my $set_default_repo_test = "and don't update the default repo to be the current dir";
    my $new_default_repo;
    if (open(DEFAULT_REPO,'<./_darcs/prefs/defaultrepo')) {
        $new_default_repo = (<DEFAULT_REPO>);
        close(DEFAULT_REPO);
    }

    unlike($new_default_repo,qr/temp1/,$set_default_repo_test);

    chdir '../';     # now outside of any repo
}