AnyEvent-Git-Wrapper

 view release on metacpan or  search on metacpan

t/basic_nb.t  view on Meta::CPAN

use IO::File;
use AnyEvent;
use AnyEvent::Git::Wrapper;
use File::Spec;
use File::Path qw(mkpath);
use POSIX qw(strftime);
use Sort::Versions;
use Test::Deep;
use Test::Exception;

#my $global_timeout = AE::timer 30, 0, sub { say STDERR "TIMEOUT!"; exit 2 };

my $dir = tempdir(CLEANUP => 1);

my $git = AnyEvent::Git::Wrapper->new($dir);

my $version = $git->version(AE::cv)->recv;
if ( versioncmp( $git->version(AE::cv)->recv , '1.5.0') eq -1 ) {
  plan skip_all =>
    "Git prior to v1.5.0 doesn't support 'config' subcmd which we need for this test."
}

t/basic_nb.t  view on Meta::CPAN

    if ( versioncmp( $git->version , '1.7.0.5') eq -1 ) {
      skip 'testing old git without commit --allow-empty-message support' , 1;
    }

    # Test empty commit message
    IO::File->new(">" . File::Spec->catfile($dir, qw(second_commit)))->print("second_commit\n");
    $git->add('second_commit', AE::cv)->recv;

    do {
      my $cv = AE::cv;
      my $w = AE::timer 5, 0, sub { $cv->send(0) };
      $git->commit(sub { $cv->send(1)});
      ok $cv->recv, 'Attempt to commit interactively fails quickly';
    };
    
    my $error;
    my $timeout = do {
      my $cv = AE::cv;
      my $w = AE::timer 5, 0, sub { $cv->send(1) };
      $git->commit({ message => "", 'allow-empty-message' => 1 }, sub { $error = $@ unless eval { shift->recv }; $cv->send(0) });
      $cv->recv;
    };

    if ( $error && !$timeout ) {
      my $msg = substr($error,0,50);
      skip $msg, 1;
    }

    @log = $git->log(AE::cv)->recv;



( run in 1.025 second using v1.01-cache-2.11-cpan-49f99fa48dc )